I wrote:
> I started to look at this again, and now I'm thinking that there is
> indeed an issue related to "Query 1".
Oh, scratch that, I see my mistake: I was thinking of "1" as a
constant, but actually we must be interpreting it per SQL92 rules
as a reference to output column 1. So that's why adding or dropping
the "id" output column changes the results of the grouping.
-ENOCAFFEINE ... sorry for the noise. I'll go back to studying
the HAVING issue.
regards, tom lane