// Oracle error reference

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
Error message
not a single-group group function

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 employees with no GROUP BY.
  • Adding a column to a report query and forgetting the GROUP BY.

How to fix it

  1. Group by the non-aggregated columns.

    SELECT department_id, COUNT(*)
    FROM hr.employees
    GROUP BY department_id;
  2. 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

More syntax and sql statements errors

The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.

// fewer errors, faster fixes

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.