HAVING without GROUP BY cluase is valid and works on the whole table. From the SQL 92 standard:
7.10
:: = HAVING
Syntax Rules
1) Let HC -. Let TE be the one that immediately contains HC.
If TE does not immediately contain a, then GROUP BY () is implicit.
and
:: = GROUP BY
<grouping specification> ::= <grouping column reference> | <rollup list> | <cube list> | <grouping sets list> | <grand total> | <concatenated grouping> <grouping set> ::= <ordinary grouping set> | <rollup list> | <cube list> | <grand total> <grand total> ::= <left paren> <right paren>
As you can see, GROUP BY () considered as grand total .
In your example, you have:
select 1 where 1!=1 having count(*)=0;
actually something like:
select 1 where 1!=1 -- group by () having count(*)=0;
source share