Re: group by can use alias from select list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, postgres-hape(at)gmx(dot)de, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: group by can use alias from select list
Date: 2023-09-07 00:01:30
Message-ID: 1591985.1694044890@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> On Tue, Jul 11, 2023 at 07:31:26AM -0700, David G. Johnston wrote:
>> I think the complaint is that someone seeing the behavior in the wild comes to
>> this order-of-operations and doesn't see that the observed behavior is
>> documented.

> How is the attached patch?

Maybe better "Although query output columns are nominally computed in the
next step, they can also be referenced (by name or by ordinal number)
as <literal>GROUP BY</literal> elements".

You could go further and add "Such references cannot be parts of
<literal>GROUP BY</literal> expressions, however." Not sure if we
cover that explicitly anywhere else.

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2023-09-07 14:11:00 Re: group by can use alias from select list
Previous Message Bruce Momjian 2023-09-06 23:51:34 Re: group by can use alias from select list