How to resolve ORA-00979 Error Message in Oracle database

Learn the reason and how to unravel the ORA-00979 error message in Oracle.

Description

When you come across an ORA-00979 error, the following error message will appear:

ORA-00979: not a GROUP BY expression

Cause

You tried to execute a SELECT assertion that protected a GROUP BY feature (ie: MIN Function, MAX Function, SUM Function, COUNT Function) and an expression in the SELECT list that was once not in the GROUP BY clause.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Rewrite the SELECT assertion so that the column or expression listed in the SELECT listing is also found in the GROUP BY clause.

Option #2

Remove the GROUP BY feature (ie: MIN Function, MAX Function, SUM Function, COUNT Function) from the SELECT statement.

Option #3

Remove the expression from the SELECT listing that was no longer in the GROUP BY clause.

For example, if you had tried to execute the following SELECT statement:

SELECT department, company, MIN(salary) AS "Lowest salary"
FROM employees
GROUP BY department;

You would receive the following error message:

You should right this by way of together with business enterprise in the GROUP BY clause as follows:

SELECT department, company, MIN(salary) AS "Lowest salary"
FROM employees
GROUP BY department, company;