DBAtlas · Database operations atlas

ORA-00979: not a GROUP BY expression

Oracle

What does it mean?

A non-aggregated column was used in the SELECT list together with an aggregate function (SUM, COUNT, etc.), but the column was not added to the GROUP BY clause. Oracle does not know how to group that column.

Why does it happen?

A column in the SELECT but not in the GROUP BY; expressions outside aggregate functions missing from the GROUP BY list; inconsistency in HAVING or select expressions.

How to fix it

Add all non-aggregated columns to the GROUP BY list: SELECT department, COUNT(*) FROM employee GROUP BY department; Alternatively, wrap that column in an aggregate function (MAX, MIN) too, or redesign the grouping with an analytic function (OVER()).

Open in DBAtlas →

More from this engine