Re: Horizontal aggregation?

From: Abel Abraham Camarillo Ojeda <acamari(at)the00z(dot)org>
To: hamann(dot)w(at)t-online(dot)de
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Horizontal aggregation?
Date: 2012-04-14 06:28:12
Message-ID: CAPD=2Nhsqt_iB156QgOrNPRCJsHjXJVZixpovoXo8f8fAFkFmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Apr 14, 2012 at 1:22 AM, <hamann(dot)w(at)t-online(dot)de> wrote:
>
>
> Hi,
>
> I am looking for a feature that would select from a table with
> k1  a
> k1  b
> k1  c
> k2  a
> k3  b
> k3  c
> something like
> k1  a b c
> k2  a
> k3  b c
> (Just all elements next to each other, with a space in between)
> or perhaps an array output
> k1  {a,b,c]
> k2  {a}
> k3  {b,c}
>
> If such an operator exists, would there be a "remove duplicates" option?
>
> Regards
> Wolfgang Hamann
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

select k, array_agg(distinct val ) from t;

See the docs: http://www.postgresql.org/docs/9.1/static/sql-expressions.html#SYNTAX-AGGREGATES

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Abel Abraham Camarillo Ojeda 2012-04-14 06:29:00 Re: Horizontal aggregation?
Previous Message hamann.w 2012-04-14 06:22:56 Horizontal aggregation?