Skip to content
Advertisement

Group by expression with case statement in oracle?

I have a query with case statement in it.

This query gives me error

ORA-00979: not a GROUP BY expression

When I remove my last case statement from select then it runs fine. Please help me in this

Advertisement

Answer

Columns that aren’t aggregated should be part of the GROUP BY clause. It means that “solution”

  • isn’t to remove the 2nd CASE from SELECT, but to
  • include it into GROUP BY

Something like this (CTE is here just to have some sample data in order to show that query works; does it produce what you meant it to, I can’t tell):

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement