OracleORA-00979

ORA-00979: Not a GROUP BY Expression

ORA-00979 is raised when a SELECT clause contains a non-aggregated column that is not listed in the GROUP BY clause. Oracle enforces strict GROUP BY rules unlike MySQL's older default mode.

Example Query

SELECT department_id, name, COUNT(*)
FROM employees
GROUP BY department_id;
-- 'name' must appear in GROUP BY or be aggregated

Common Causes

  1. 1SELECT list includes columns not in GROUP BY and not wrapped in aggregate functions
  2. 2Migrating a query from MySQL (which allows this in older modes) to Oracle
  3. 3Selecting a computed expression not in GROUP BY

How to Fix It

Add all non-aggregated SELECT columns to the GROUP BY clause. Use aggregate functions (MAX, MIN, LISTAGG) if you want to include a column without grouping by it. Use analytic functions (ROW_NUMBER, FIRST_VALUE) for more complex scenarios.

Need a reliable database?

Try Supabase — free PostgreSQL with a generous free tier. No credit card required.

Get started free →

Got a query causing this error?

Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.

Analyze My Query →