Home » SQL & PL/SQL » SQL & PL/SQL » Date as column header and below result (Oracle 8.1.7 / WINDOWS XP)
Date as column header and below result [message #283651] Tue, 27 November 2007 20:10 Go to next message
kumarvk
Messages: 211
Registered: July 2004
Senior Member
I have the following sql:

SELECT
TO_DATE(a.APPT_dtime,'DD-MON-YY') APPT_DATE,
COUNT(DISTINCT A.APPT_NO) "PER DAY"
FROM MSS_appt_HDR A
WHERE A.appt_DTIME BETWEEN TO_DATE('01-JAN-07 00:00:00', 'dd-mon-yy hh24:mi:ss')
AND TO_DATE('31-JAN-07 23:59:59', 'dd-mon-yy hh24:mi:ss')
AND A.STS != 'X'
GROUP BY TO_DATE(A.APPT_dtime,'DD-MON-YY')

My result

APPT_DATE PER DAY
03-Jan-07 18
04-Jan-07 30
05-Jan-07 30
06-Jan-07 8
08-Jan-07 34
09-Jan-07 35
10-Jan-07 32
11
12
..
..
..
31-Jan-07

Now I want the above output as

Month 1 2 3 4 5 6 7 8 9 10 . . . . . . . . . 31
Jan 18 30 30 8 34 35 32 . . . . . . . . . 28

Can anyone able to help me in this regard? Thanks
Re: Date as column header and below result [message #283658 is a reply to message #283651] Tue, 27 November 2007 21:16 Go to previous message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
search this forum for "pivot query"
Previous Topic: setting SQL%ROWCOUNT in stored procedure
Next Topic: Condition in query
Goto Forum:
  


Current Time: Fri Dec 09 15:54:32 CST 2016

Total time taken to generate the page: 0.18194 seconds