Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report formating

Status
Not open for further replies.

Matsul

IS-IT--Management
May 6, 2002
140
BE
I am running a query

select type,date,count(*)
from tableA
group by type,date;

that gives me data as follows in a more simple example;

Type Date Count
A 1-12-04 100
B 1-12-04 50
D 1-12-01 150
A 2-12-04 75
B 2-12-01 40

Is there a way in PL/SQL to 'transpose' the data to get a report as follows

Date
-------------------
Type |1-12-04 2-12-04
|
A |100 75
B |50 40
D |150


thanks
 
You're going to have to use a DECODE statement on the query to evaluate the dates.

Try something like:

Select Type,
Count(Decode(date,To_Date('01-12-04','MM-DD-YY'),1)) "01-12-04",
Count(Decode(date,To_Date('02-12-04','MM-DD-YY'),1)) "02-12-04"
From TableA
Group By Type

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top