SQL Language (MOSC)

MOSC Banner

Discussions

HAVING clause without GROUP BY?

edited May 3, 2016 11:33AM in SQL Language (MOSC) 3 commentsAnswered

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?

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center