order by alias - doesn't work sometimes?

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема order by alias - doesn't work sometimes?
Дата
Msg-id aO5jUGlQgBBAOp4_@depesz.com
обсуждение исходный текст
Ответы Re: order by alias - doesn't work sometimes?
Список pgsql-bugs
Hi,
It very well might not be a bug, but it caught me by surprise.

Tested on Pg 19 from git head:

=$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x;
 x
───
 a
 c
 d
(3 rows)

Works, and shows that I can order by alias name of column that is generated by srf.

But:

=$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a';
ERROR:  column "x" does not exist
LINE 1: select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a';
                                                         ^

Obviously I can put the unnest() call in from, and then it works, but
I'm curious, why we can `order by x`, but not `order by x <> 'a'` ?

Best regards,

depesz




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