SELECT DISTINCT ON removes results

Поиск
Список
Период
Сортировка
От Guyren Howe
Тема SELECT DISTINCT ON removes results
Дата
Msg-id AF05A411-E3A8-4317-8D6B-D4D658991C8B@gmail.com
обсуждение исходный текст
Ответы Re: SELECT DISTINCT ON removes results  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: SELECT DISTINCT ON removes results  (Geoff Winkless <pgsqladmin@geoff.dj>)
Список pgsql-general
Using 9.5, this query:

SELECT o.id,
a.number AS awb
FROM pt.orders o
LEFT JOIN (
SELECT DISTINCT ON ((string_agg(air_way_bills.number::text, ','::text)))
string_agg(air_way_bills.number::text, ','::text) AS number,
air_way_bills.order_id
FROM pt.air_way_bills
GROUP BY air_way_bills.order_id) a ON a.order_id = o.id
gives me null for awb. Removing the DISTINCT ON clause:

SELECT o.id,
a.number AS awb
FROM pt.orders o
LEFT JOIN (
SELECT string_agg(air_way_bills.number::text, ','::text) AS number,
air_way_bills.order_id
FROM pt.air_way_bills
GROUP BY air_way_bills.order_id) a ON a.order_id = o.id
where o.id = 2792;
gives me an awb. I'm confused about how this can be.

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: How to hint 2 coulms IS NOT DISTINCT FROM each other
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: SELECT DISTINCT ON removes results