pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: postgres-hape@gmx.de
To: pgsql-docs@lists.postgresql.org
Subject: Re: group by can use alias from select list
Date: Tue, 11 Jul 2023 16:19:48 +0200
Message-ID: <25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at> (raw)
In-Reply-To: <168871536004.379168.9352636188330923805@wrigleys.postgresql.org>
References: <168871536004.379168.9352636188330923805@wrigleys.postgresql.org>

On Fri, 2023-07-07 at 07:36 +0000, PG Doc comments form wrote:
> i have a discussion in pgsql-bugs@lists.postgresql.org about this and it is
> mentioned in the answers that it is documented and a "feature" of Postgres
> that this can be done.
> If this is wanted the documentation
> (https://www.postgresql.org/docs/current/sql-select.html) that mentioned:
> [execution order of SELECT that says that GROUP BY is before SELECT]
> isn't correct because how  can 4.) be done and the alias from 5.) is used?
> Here is a hint important that there is an exception for alias used in group
> by

I think that is already documented:

> An expression used inside a grouping_element can be an input column name,
> or the name or ordinal number of an output column (SELECT list item),
> or an arbitrary expression formed from input-column values.

An alias in this case would be an output column.  Perhaps we can mention
the alias explicitly.

Yours,
Laurenz Albe





view thread (7+ messages)  latest in thread

Message-ID: <25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at>
Permalink:  ../25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at/
Also on:    postgresql.org/message-id/25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at

 · 

reply

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-docs@postgresql.org
  Cc: laurenz.albe@cybertec.at, postgres-hape@gmx.de, pgsql-docs@lists.postgresql.org
  Subject: Re: group by can use alias from select list
  In-Reply-To: <25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at>

* 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