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=1How does the second query work without any GROUP BY clause?