Results 1 to 4 of 4

Thread: crosstab

  1. #1
    Join Date
    Dec 2003
    Posts
    1,074

    Unanswered: crosstab

    I'm looking for information on SQL syntax for pivoting data, for crosstab output. I do not know what keywords to search on. Could someone provide?

    Thanks,
    Chuck

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Sometimes called a "pivot" query, you can do it like this:
    Code:
    select deptno,
             sum(decode(job,'MANAGER',sal,0)) as manager_sal,
             sum(decode(job,'CLERK',sal,0)) as clerk_sal,
    ... etc.
    from emp
    group by deptno;
    Is that what you had in mind?

  3. #3
    Join Date
    Dec 2003
    Posts
    1,074
    That is what I had in mind, but I was hoping that Oracle had a keyword, like MSAccess's TRANSFORM, which pivoted data without knowing the number of columns that would be generated in advance.

    -cf

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    No, sorry!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •