The following query returns a wrong result, in my opinion.
postgres=# select 1 where false having true;
?column?
----------
1
(1 row)
The correct result should be zero rows.
According to the General Rules of 7.13 <group by clause>, the lack of a
GROUP BY clause means the result of the WHERE clause is the sole group.
Because of the WHERE FALSE, we should have either a single group with no
rows, or no groups, depending on how you look at it.
The General Rules of 7.14 <having clause> dictate that all groups where
the HAVING clause evaluates to TRUE are to be output. That will always
be the case for this query, so regardless of if we have no groups or one
group with no rows, the result should be empty.
I cannot find any justification anywhere for why this query should emit
any values at all.
Hat tip to Lukas Eder:
https://twitter.com/lukaseder/status/1588150810466205697
--
Vik Fearing