What This Error Means
This error occurs when a SELECT statement includes a column that is not included in the GROUP BY clause, or when a SELECT statement includes an aggregate function without grouping the data.
Why It Happens
This error typically happens when a query is trying to select a column that has been modified by an aggregate function, but the column is not included in the GROUP BY clause. This can also occur when a query is trying to select a column that has been modified by a window function, but the column is not included in the OVER clause.
How to Fix It
- 1To fix this error, you need to either include the column in the GROUP BY clause, or use a subquery to group the data before selecting the column. Alternatively, you can use a window function that allows you to select the column without grouping the data, such as ROW_NUMBER() or RANK().
Example Code Solution
❌ Before (problematic code)
SQL
SELECT id, SUM(salary) as total_salary FROM employees GROUP BY id, name;✅ After (fixed code)
SQL
SELECT id, name, SUM(salary) as total_salary FROM (SELECT id, name, salary FROM employees) GROUP BY id, name;Fix for ORA-00979: not a GROUP BY expression
Browse Related Clusters
Related SQL Errors
Related SQL Blog Articles
Have a different error? Get an instant explanation.
Explain Another Error