Re: Converting row elements into a arrays?

From: Ray O'Donnell <ray(at)rodonnell(dot)ie>
To: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Converting row elements into a arrays?
Date: 2023-03-02 21:02:41
Message-ID: d1b8c339-fa71-8fac-907d-abb6a2478910@rodonnell.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/03/2023 21:01, Ray O'Donnell wrote:
> On 02/03/2023 20:58, Ron wrote:
>> Postgresql 12.13
>>
>> Given the sample below, I'm looking for how to generate this output.
>> It's like GROUP BY, but generating an array instead of an aggreate
>> number.
>>   f1 | f2_array
>> ----+---------
>> 1 | {1,2,3}
>>    2 | {1,2,3,4}
>>    3 | {1,2}
>
> Something like this (off the top of my head)? -
>
>    select f1, array_agg(f2) as f2_array group by f1;

... from foo ...

R.

--
Raymond O'Donnell // Galway // Ireland
ray(at)rodonnell(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-03-02 21:34:29 Re: Converting row elements into a arrays?
Previous Message Ray O'Donnell 2023-03-02 21:01:22 Re: Converting row elements into a arrays?