Reputation: 6478
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
Upvotes: 1
Views: 3786
Reputation: 17304
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
Upvotes: 4
Reputation: 2570
This error is caused by:
Cause: The SQL statement ends with an inappropriate clause. For example, an ORDER BY clause may have been included in a CREATE VIEW or INSERT statement. ORDER BY cannot be used to create an ordered view or to insert in a certain order.
You have WHERE after GROUP BY
Change the query to:
SELECT COUNT(*), ACTION_DATE
FROM SUMMARY
WHERE NUM_ACTIONS = 500
GROUP BY ACTION_DATE;
Upvotes: 2