Quantcast
Channel: beyondrelational.com
Viewing all articles
Browse latest Browse all 25

Question of the month February 2013 - How does HAVING clause work without GROUP BY Clause?

$
0
0

When you run the following code

select name from sys.objects
having 1=1

you get the following error
Msg 8120, Level 16, State 1, Line 2
Column 'sys.objects.name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

But the follwing query runs fine without any problem
select 1
having 1=1
How does the second query work without any GROUP BY clause?

Viewing all articles
Browse latest Browse all 25

Trending Articles