From: Tom Lane <tgl@sss.pgh.pa.us>
To: Carlos Sotto Maior \(UOL\) <csotto@uol.com.br>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Use of HAVING (Select/Group By) on a output-name of an aggregate function causes SYNTAX ERROR
Date: Sat, 30 Jan 2021 17:46:29 -0500
Message-ID: <3011179.1612046789@sss.pgh.pa.us> (raw)
In-Reply-To: <01ca01d6f759$00c24510$0246cf30$@uol.com.br>
References: <01ca01d6f759$00c24510$0246cf30$@uol.com.br>
"Carlos Sotto Maior \(UOL\)" <csotto@uol.com.br> writes:
> In other words: Postgresql is matching <HAVING> arguments to columns at
> table level instead of matching to a group by result level.
That's per SQL standard. The fact that we allow the case in
GROUP BY is an anachronism. (You'll find also that we only allow it
for GROUP BY items that are *just* an output column name, not any
more-complicated expression. The equivalent restriction for HAVING
would make such a feature near useless anyway.)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, csotto@uol.com.br, pgsql-bugs@lists.postgresql.org
Subject: Re: Use of HAVING (Select/Group By) on a output-name of an aggregate function causes SYNTAX ERROR
In-Reply-To: <3011179.1612046789@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox