"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, February 4, 2016, <tarasbob@gmail.com> wrote:
>> The following query incorrectly returns 1 row instead of 0:
>>
>> SELECT 1
>> FROM some_table
>> WHERE FALSE
>> HAVING TRUE
> So, amazingly (to me), this behavior is documented.
>> The presence of HAVING turns a query into a grouped query even if there is
>> no GROUP BY clause. ... Such a
>> query will emit a single row if the HAVING condition is true, zero rows if
>> it is not true.
Yeah. This is a pretty weird corner case, but the behavior is required
by SQL spec.
regards, tom lane