Resolve ORA-00924 Error Message in Oracle

Learn the reason and how to resolve the ORA-00924 error message in Oracle.

Description

When you stumble upon an ORA-00924 error, the following error message will appear:

ORA-00924: missing BY keyword

Cause

You tried to execute a GROUP BY, ORDER BY, CONNECT BY, or GRANT (with IDENTIFIED) declaration and missed the BY keyword.

Resolution

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

Option #1

Try adding the lacking BY key-word and re-execute the statement.

For example, if you tried to execute the following:

SELECT department, SUM(sales) AS "Total sales"
FROM order_details
GROUP department;

You would receive the following error message:

You ought to correct this error with the following statement:

SELECT department, SUM(sales) AS "Total sales"
FROM order_details
GROUP BY department;