Re: ARRAY_AGG and ORDER - Mailing list pgsql-general

From Geoff Winkless
Subject Re: ARRAY_AGG and ORDER
Date
Msg-id CAEzk6ff=FzF_JnPgxka8CVxubvAsn=r9COXJgpiWuLOAs4vvOw@mail.gmail.com
Whole thread Raw
In response to ARRAY_AGG and ORDER  ("Sterpu Victor" <victor@caido.ro>)
List pgsql-general
On 26 November 2015 at 12:43, Sterpu Victor <victor@caido.ro> wrote:
Hello
 
I need to order an array using another column in table ad_query_join_select.
I need something like this but this is not a valid SQL:
SELECT array_to_string(array_agg(aqjs.id ORDER BY aqjs.to_left), ',') AS str, aq.name
FROM ad_query aq
JOIN ad_query_join_select aqjs ON (aqjs.id_ad_query = aq.id)
GROUP BY aq.id, aq.name;
 
Is there some equivalent syntax in Postgres?
 
​As per the manual?


SELECT string_agg(a, ',' ORDER BY a) FROM table;

pgsql-general by date:

Previous
From: "Sterpu Victor"
Date:
Subject: ARRAY_AGG and ORDER
Next
From: "Sterpu Victor"
Date:
Subject: Re: ARRAY_AGG and ORDER