Re: ARRAY_AGG and ORDER - Mailing list pgsql-general

From Sterpu Victor
Subject Re: ARRAY_AGG and ORDER
Date
Msg-id em0337b323-952a-4e65-be90-42d590d5b4dd@victor-pc
Whole thread Raw
In response to ARRAY_AGG and ORDER  ("Sterpu Victor" <victor@caido.ro>)
List pgsql-general
Yes, thank you. :)
 
------ Original Message ------
From: "Sterpu Victor" <victor@caido.ro>
To: "Geoff Winkless" <pgsqladmin@geoff.dj>
Sent: 11/26/2015 2:51:48 PM
Subject: Re[2]: [GENERAL] ARRAY_AGG and ORDER
 
Yes, thank you. :)
 
 
------ Original Message ------
From: "Geoff Winkless" <pgsqladmin@geoff.dj>
To: "Sterpu Victor" <victor@caido.ro>
Cc: "PostgreSQL General" <pgsql-general@postgresql.org>
Sent: 11/26/2015 2:46:33 PM
Subject: Re: [GENERAL] ARRAY_AGG and ORDER
 
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;

DISCLAIMER:
Acest mesaj de posta electronica si documentele aferente sunt confidentiale. Este interzisa distribuirea, dezvaluirea sau orice alt mod de utilizare a lor. Daca nu sunteti destinatarul acestui mesaj, este interzis sa actionati in baza acestor informatii. Citirea, copierea, distribuirea, dezvaluirea sau utilizarea in alt mod a informatiei continute in acest mesaj constituie o incalcare a legii. Daca ati primit mesajul din greseala, va rugam sa il distrugeti, anuntand expeditorul de eroarea comisa. Intrucat nu poate fi garantat faptul ca posta electronica este un mod sigur si lipsit de erori de transmitere a informatiilor, este responsabilitatea dvs. sa va asigurati ca mesajul (inclusiv documentele alaturate lui) este validat si autorizat spre a fi utilizat in mediul dvs.

pgsql-general by date:

Previous
From: Geoff Winkless
Date:
Subject: Re: ARRAY_AGG and ORDER
Next
From: krichy@tvnetwork.hu
Date:
Subject: long transactions / backend memory usage