ORA-00937: not a single-group group function
The select list mixes an aggregate like COUNT or SUM with plain columns, and there is no GROUP BY for those columns.
- Error code
ORA-00937- Category
- Syntax and SQL statements
What it means
Without GROUP BY, a query with an aggregate returns one row for the whole table, so plain columns in the select list have no single value to show. ORA-00937 means you combined both.
Common causes
SELECT department_id, COUNT(*) FROM employeeswith noGROUP BY.- Adding a column to a report query and forgetting the
GROUP BY.
How to fix it
-
Group by the non-aggregated columns.
SELECT department_id, COUNT(*) FROM hr.employees GROUP BY department_id;
-
If you want the aggregate next to every row, use an analytic function instead.
SELECT employee_id, department_id, COUNT(*) OVER (PARTITION BY department_id) AS dept_count FROM hr.employees;
Related errors
ORA-00979not a GROUP BY expression8118SQL Server: Aggregate without GROUP BY8120SQL Server: Column not in GROUP BY or aggregate1055MySQL: Expression isn't in GROUP BY42803PostgreSQL: column must appear in the GROUP BY clause
More syntax and sql statements errors
ORA-00933SQL command not properly endedORA-00936missing expressionORA-00907missing right parenthesisORA-00911invalid characterORA-00917missing commaORA-00918column ambiguously definedORA-00923FROM keyword not found where expectedORA-01427single-row subquery returns more than one row
The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.
Work on Oracle in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.