Re: help with aggregation query across a second text array column - Mailing list pgsql-general

From Rob Nikander
Subject Re: help with aggregation query across a second text array column
Date
Msg-id FA3E2516-6BDC-46CB-B5B5-793AED4D7334@gmail.com
Whole thread Raw
In response to help with aggregation query across a second text array column  (Scot Kreienkamp <Scot.Kreienkamp@la-z-boy.com>)
Responses RE: help with aggregation query across a second text array column
List pgsql-general

> On Nov 12, 2018, at 9:40 AM, Scot Kreienkamp <Scot.Kreienkamp@la-z-boy.com> wrote:
> …

I’m not too confident in my answer here (there could be a better way), but this might help. You could use the `unnest`
functionto transform the array into multiple rows. For example, given a table like  

    create table t1 (env text, cls text, cls2 text[]);

I can query it like:

    select env, string_agg(cls, ‘,’)
      from (select env, cls from t1
               union
               select env, unnest(cls2) from t1) t
    group by env;

Rob

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: libwinpthread-1.dll missing in PostgreSQL 11.0-1 for Windows
Next
From: Marko Krajnc
Date:
Subject: Re: libwinpthread-1.dll missing in PostgreSQL 11.0-1 for Windows