From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | emilu(at)encs(dot)concordia(dot)ca |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: "select c1, method(c2) group by c1" returns all values of c2 for c1 |
Date: | 2011-02-08 19:43:19 |
Message-ID: | AANLkTimZi_ouNUm8EOyL8RmL5Op-TQwfTwJ4_4NQspFF@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello
you can use a string%agg function if you have a 9.0. On older version
there is a array_agg function
select c1, array_to_string(array_agg(c2),',') from T1 group by c1
regards
Pavel Stehule
2011/2/8 Emi Lu <emilu(at)encs(dot)concordia(dot)ca>:
> Good afternoon,
>
> Is there a method to retrieve the following results:
>
> T1(c1 int, c2 varchar(128) )
> ---------------------------------
>
>
> (1, val1);
> (1, val2);
> (1, val3);
> (2, val1);
> (3, val5);
> (3, val6);
>
> select c1, method(c2)
> group by c1
>
> returns:
> ============
> 1, "val1, val2, val3"
> 2, "val1"
> 3, "val5, val6"
>
>
> Thanks a lot!
>
> --
> Lu Ying
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Steinheuser | 2011-02-08 19:43:23 | Re: "select c1, method(c2) group by c1" returns all values of c2 for c1 |
Previous Message | Emi Lu | 2011-02-08 19:35:38 | "select c1, method(c2) group by c1" returns all values of c2 for c1 |