Discussions
HAVING clause without GROUP BY?
Hello,
A colleague of mine sent me a query where he used a HAVING clause without a GROUP BY one, and the query works.
According to the SQL Reference manual, it should not:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10002.htm#i2078943
Specify GROUP BY and HAVING after the where_clause and hierarchical_query_clause.
Tested on 11.2.0.3 and 11.2.0.4.
You can test with the following query:
SELECT *
FROM (select object_name, 1 dummy from user_objects)
HAVING dummy = 1;
Shouldn't there be a syntax error raised?
1