group by can use alias from select list but not the having clause

From: hape Hape <postgres-hape(at)gmx(dot)de>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: group by can use alias from select list but not the having clause
Date: 2023-07-03 09:43:21
Message-ID: trinity-c2f74081-7c6f-4b9c-b4cc-67c301118083-1688377401497@3c-app-gmx-bs14
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><p>hi</p>

<p>my understanding from SQL sequence is:</p>

<p>from - where - group by - having - select - order by - limit</p>

<p>but</p>

<p>with tbase(id)<br/>
as (select 1 union all select 2)<br/>
select id otto from tbase<br/>
group by otto<br/>
order by otto</p>

<p>works (how does the group by know about otto if the sequence is done as described above?)</p>

<p>also the having after the group by doesn&#39;t know about otto (which in my thoughts is correct)</p>

<p>So i think its good if</p>

<p>a) the group by also doesn&#39;t know about otto</p>

<p>b) also the havings can interpret the alias otto</p>

<p>But today its half/half so its not good.</p>

<p>hape</p></div></body></html>

Attachment Content-Type Size
unknown_filename text/html 779 bytes

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2023-07-03 11:36:32 Backend handling replication slot stuck using 100% cpu, unkillable
Previous Message Amit Kapila 2023-07-03 08:50:27 Re: Toasted column values during replication. (Enhancement)