ARRAY_AGG and ORDER

From: "Sterpu Victor" <victor(at)caido(dot)ro>
To: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: ARRAY_AGG and ORDER
Date: 2015-11-26 12:43:32
Message-ID: emfd0b430c-29fb-4af6-a9cf-32d15e4c1464@victor-pc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Thank you.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoff Winkless 2015-11-26 12:46:33 Re: ARRAY_AGG and ORDER
Previous Message Sachin Srivastava 2015-11-26 11:48:03 Postgresql Dump Question