Re: group by can use alias from select list
От | Bruce Momjian |
---|---|
Тема | Re: group by can use alias from select list |
Дата | |
Msg-id | ZPnZ9ILOZcWaqoY0@momjian.us обсуждение исходный текст |
Ответ на | Re: group by can use alias from select list (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: group by can use alias from select list
|
Список | pgsql-docs |
On Wed, Sep 6, 2023 at 08:01:30PM -0400, Tom Lane wrote: > Bruce Momjian <bruce@momjian.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". I modified the text slightly in the attached patch. > 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. We do farther down the docs in the GROUP BY section: https://www.postgresql.org/docs/devel/sql-select.html GROUP BY will condense into a single row all selected rows that share the same values for the grouped expressions. 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. In case of ambiguity, a ------------------------ GROUP BY name will be interpreted as an input-column name rather than an output column name. It says * input column name * output column name or ordinal number * expression formed from input-column values Is this too subtle? -- Bruce Momjian <bruce@momjian.us> https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
Вложения
В списке pgsql-docs по дате отправления: