sqloracle-databaseora-00933

SQL/ORA-00933 SQL Command Not Properly Ended


I'm executing the following query:

select count(*),ACTION_DATE from SUMMARY group by ACTION_DATE where NUM_ACTIONS=500;

which is giving me ORA-00933 SQL Command not properly ended and I'm not sure why.

SUMMARY is the table, ACTION_DATE and NUM_ACTIONS are columns. So what I'm expecting is each date with num_actions=500.

If anybody can see what's wrong with the command it'd be appreciated, Thanks


Solution

  • The WHERE clause must be before the GROUP BY.

    See oracle documentation about SELECT

    SELECT COUNT(*), action_date
    FROM summary 
    WHERE num_actions = 500
    GROUP BY action_date