From: | shankha <shankhabanerjee(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Use of array_agg and array string on inner query |
Date: | 2016-05-19 13:02:31 |
Message-ID: | CAO_L6qG_UkYqseR8+EZGCO_DAP4ydrwxt8myDES5JhFSagszUA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I got the query:
SELECT c1, c2,
ARRAY_TO_STRING(ARRAY_AGG((SELECT t3.c1 FROM s.t1 as t3 JOIN s.t1 as
t2 ON t3.c3 = t2.c2)), ',')
FROM s.t1 t1
GROUP BY c1;
DROP SCHEMA s CASCADE;
Thanks for all the help.
Thanks
Shankha Banerjee
On Wed, May 18, 2016 at 2:40 PM, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Wed, May 18, 2016 at 2:30 PM, shankha <shankhabanerjee(at)gmail(dot)com> wrote:
>>
>> I cannot move the array_agg to around the column name. It has to work
>> as a inner query
>> .
>
>
> The following form is used to make an array from a subquery:
>
> SELECT ARRAY(SELECT i FROM ( VALUES (1), (2), (3) ) vals (i) );
>
> http://www.postgresql.org/docs/9.5/static/sql-expressions.html
>
> 4.2.12; last example
>
> Not the most obvious place...
>
> David J.
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2016-05-19 13:24:59 | Re: first_value/last_value |
Previous Message | Rene . | 2016-05-19 13:00:44 | Re: Londiste 3 pgq events_1_1 table huge |