Re: SELECT DISTINCT ON removes results - Mailing list pgsql-general

From Geoff Winkless
Subject Re: SELECT DISTINCT ON removes results
Date
Msg-id CAEzk6fdpXWWpZxZJbhLoEC3qE-zCaFg8uXU6gxiwNZpavu30Bg@mail.gmail.com
Whole thread Raw
In response to SELECT DISTINCT ON removes results  (Guyren Howe <guyren@gmail.com>)
List pgsql-general
On 28 October 2016 at 21:39, Guyren Howe <guyren@gmail.com> wrote:
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
The DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s). The ORDER BY clause will normally contain additional expression(s) that determine the desired precedence of rows within each DISTINCT ON group.
 

​Does the problem go away if you do that?​

​Geoff​

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: initdb createuser commands
Next
From: Samuel Williams
Date:
Subject: Re: initdb createuser commands