From: | "Carlos Sotto Maior (UOL)" <csotto(at)uol(dot)com(dot)br> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | RE: Use of HAVING (Select/Group By) on a output-name of an aggregate function causes SYNTAX ERROR |
Date: | 2021-01-31 00:00:40 |
Message-ID: | 6015f32810472_761d2ac39d33710c286fd@ip-10-81-19-78.ec2.internal.mail |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Thanks a lot Tom.<br />
I'll solve it with a subquery.
<p>Carlos Sotto Maior (UOL)<br />
<a href="mailto:csotto(at)uol(dot)com(dot)br">csotto(at)uol(dot)com(dot)br</a></p>
<p> </p>
<hr />
<div><br />
<strong>De: </strong>"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us><br />
<strong>Enviada: </strong>2021/01/30 19:46:37<br />
<strong>Para: </strong>csotto(at)uol(dot)com(dot)br<br />
<strong>Cc: </strong> pgsql-bugs(at)lists(dot)postgresql(dot)org<br />
<strong>Assunto: </strong> Re: Use of HAVING (Select/Group By) on a output-name of an aggregate function causes SYNTAX ERROR<br />
</div>
"Carlos Sotto Maior \(UOL\)" <csotto(at)uol(dot)com(dot)br> writes:<br />
> In other words: Postgresql is matching <HAVING> arguments to columns at<br />
> table level instead of matching to a group by result level.<br />
<br />
That's per SQL standard. The fact that we allow the case in<br />
GROUP BY is an anachronism. (You'll find also that we only allow it<br />
for GROUP BY items that are *just* an output column name, not any<br />
more-complicated <span>expression</span>. The equivalent restriction for HAVING<br />
would make such a feature near useless anyway.)<br />
<br />
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/html | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2021-01-31 09:09:49 | BUG #16846: "retrieved too many tuples in a bounded sort" |
Previous Message | Tom Lane | 2021-01-30 22:46:29 | Re: Use of HAVING (Select/Group By) on a output-name of an aggregate function causes SYNTAX ERROR |