Search Postgresql Archives

Re: help with aggregation query across a second text array column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Nov 12, 2018, at 9:40 AM, Scot Kreienkamp <Scot.Kreienkamp@xxxxxxxxxxxx> 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` function to 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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux