How to PIVOT in Oracle 8i

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • napstar
    New Member
    • Nov 2006
    • 55

    How to PIVOT in Oracle 8i

    I need to generate the count of new subscribers per day for a cable company,I can generate the rows vertically but I need to turn them into columns in oracle 8i.How do I generate the following output?
    1-Jan-09 2-Jan-09 3-Jan-09 4-Jan-09 5-Jan-09 6-Jan-09
    count
    Thnaks
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    This sample code might help:

    Code:
    SELECT SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_10,
    SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_20,
    SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_30,
    SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_40
    FROM 
    dept;

    Comment

    Working...