Functions in sort order - undocumented restriction

Поиск
Список
Период
Сортировка
От PG Doc comments form
Тема Functions in sort order - undocumented restriction
Дата
Msg-id 151826283029.1443.7699948679319699778@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: Functions in sort order - undocumented restriction  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Functions in sort order - undocumented restriction  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Functions in sort order - undocumented restriction  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-docs
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/static/queries-order.html
Description:

This works:

select distinct o.bid, organisation, posttown, replace(case when phone =''
then null else trim(phone) end, ' ', ''), phone, o.active, website, email,
(select count(*) from notes as n where n.bid = o.bid) as nn from
organisations as o right join notes as n on o.bid = n.bid where true order
by replace(case when phone ='' then null else trim(phone) end, ' ', '')
nulls last ;

This does not work:

 select distinct (o.bid), organisation, posttown, replace(case when postcode
='' then null else trim(postcode) end, ' ', '') as pc, phone, o.active,
website, email, (select count(*) from notes as n where n.bid = o.bid) as nn
from organisations as o right join notes as n on o.bid = n.bid where true
order by replace(case when phone ='' then null else trim(phone) end, ' ',
'') nulls last ;
ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select
list
LINE 1: ...n notes as n on o.bid = n.bid where true order by replace(ca...

The documentation does not explain the restriction, nor that, or why, you
cannot use 'as' to rename the field and then cite the renamed version.

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

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: Engineering
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Documentation of EXCEPT ALL may have a bug