Connecting Tech Pros Worldwide Help | Site Map

How to PIVOT in Oracle 8i

Member
 
Join Date: Nov 2006
Posts: 44
#1: Mar 12 '09
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's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#2: Mar 12 '09

re: How to PIVOT in Oracle 8i


This sample code might help:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_10,
  3. SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_20,
  4. SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_30,
  5. SUM(CASE WHEN deptno = 10 then 1 ELSE 0 END) dept_40
  6. FROM 
  7. dept;
  8.  
Reply