I'm currently trying to use a case statement before a group by command. Getting the below error
ORA-00979: not a GROUP BY expression 00979. 00000 - "not a GROUP BY expression" *Cause:
*Action: Error at Line: 188 Column: 12
select "CUSIP", "SIDE", TRADEDATE, ACCOUNTNO, SUM("QUANTITY") as CompressedQuantity,
(case when quantity = 0 THEN 0 ELSE trunc(sum("PRICE"*"QUANTITY")/sum("QUANTITY"),6) END) as AVERAGEPRICE
from rawtable
group by "SIDE", "TRADEDATE", "ACCOUNTNO", "CUSIP")
select CompressedQuantity,"SIDE", "TRADEDATE", "ACCOUNTNO", "CUSIP" FROM compresstable
;