Re: BUG #18542: Order by expression, that contains column from projection isn't working

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #18542: Order by expression, that contains column from projection isn't working
Дата
Msg-id 3319082.1721133915@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #18542: Order by expression, that contains column from projection isn't working  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> select z as y from
>  (select 1 as z) x
> order by y + 1
> That query finishes with error: 
> ERROR: column "y" does not exist
>   Position: 48
> But wrapping it with select works fine:
> select * from (select z as y from
>  (select 1 as z) x) c
> order by y + 1

This is not a bug.  See

https://www.postgresql.org/docs/current/queries-order.html

particularly "Note that an output column name has to stand alone, that
is, it cannot be used in an expression".  The fact that we allow this
at all is a hangover from SQL92; per SQL99 and later, variables in
ORDER BY should refer to input columns (that is, outputs of the FROM
clause).

            regards, tom lane



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