PIVOT QUERY NOT WORKING PLEASE HELP [message #284276] |
Thu, 29 November 2007 05:09 |
kumarvk
Messages: 214 Registered: July 2004
|
Senior Member |
|
|
SELECT
SUBSTR(A.INV_NO,1,3) "TYPE",
sum(decode(TO_CHAR(a.INV_dtime,'MON'),'JAN',SUM(B.LBR_AMT+B.MTL_AMT+B.PARTS_AMT),0)) "JAN"
FROM MSS_INV_HDR A,MSS_INV_LINES B,MSS_RO_HDR C
WHERE
c.ROST_CODE like '%SER%'
AND a.sts IN('I','S','P')
AND A.inv_dtime BETWEEN TO_DATE('01-JAN-07 00:00:00', 'dd-mon-yy hh24:mi:ss')
AND TO_DATE('30-NOV-07 23:59:59', 'dd-mon-yy hh24:mi:ss')
AND A.ID=B.INHD_ID
AND a.ROHD_ID=c.ID
AND C.MAKE_CODE IN ('T7','O7')
GROUP BY TO_CHAR(A.inv_dtime,'MON'),SUBSTR(A.INV_NO,1,3)
ORDER BY TO_DATE(TO_CHAR(A.INV_DTIME,'MON'),'MON');
I have the above sql but when i run it gives me error message
ORA-00937 not a single-group group function
I want the result like this
TYPE JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
SAC
SAD
RAD
SAI
WAR
|
|
|
|
|