Re: Use of array_agg and array string on inner query - Mailing list pgsql-general

From shankha
Subject Re: Use of array_agg and array string on inner query
Date
Msg-id CAO_L6qG_UkYqseR8+EZGCO_DAP4ydrwxt8myDES5JhFSagszUA@mail.gmail.com
Whole thread Raw
In response to Re: Use of array_agg and array string on inner query  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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.g.johnston@gmail.com> wrote:
> On Wed, May 18, 2016 at 2:30 PM, shankha <shankhabanerjee@gmail.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.
>
>


pgsql-general by date:

Previous
From: "Rene ."
Date:
Subject: Re: Londiste 3 pgq events_1_1 table huge
Next
From: "David G. Johnston"
Date:
Subject: Re: first_value/last_value