Search Postgresql Archives

Re: SELECT DISTINCT ON removes results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28 October 2016 at 21:39, Guyren Howe <guyren@xxxxxxxxx> 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​


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux