Re: group by can use alias from select list

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: group by can use alias from select list
Дата
Msg-id 25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at
обсуждение исходный текст
Ответ на group by can use alias from select list  (PG Doc comments form <noreply@postgresql.org>)
Ответы Re: group by can use alias from select list  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-docs
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



В списке pgsql-docs по дате отправления:

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: group by can use alias from select list
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: group by can use alias from select list