Re: "select c1, method(c2) group by c1" returns all values of c2 for c1 - Mailing list pgsql-sql

From Rolando Edwards
Subject Re: "select c1, method(c2) group by c1" returns all values of c2 for c1
Date
Msg-id 0ED65673FA8E634AAB252741A6CD3B5E0E7CFE3B26@lw-exchange4b.us.logicworks.net
Whole thread Raw
In response to "select c1, method(c2) group by c1" returns all values of c2 for c1  (Emi Lu <emilu@encs.concordia.ca>)
Responses Re: "select c1, method(c2) group by c1" returns all values of c2 for c1  (Emi Lu <emilu@encs.concordia.ca>)
List pgsql-sql
SELECT distinct c1,array_to_string(array(SELECT c2 FROM T1 B where A.c1=B.c1),', ') from T1 A order by c1;

Give it a Try !!!

Rolando A. Edwards
MySQL DBA (SCMDBA)

155 Avenue of the Americas, Fifth Floor
New York, NY 10013
212-625-5307 (Work)
201-660-3221 (Cell)
AIM & Skype : RolandoLogicWorx
redwards@logicworks.net
http://www.linkedin.com/in/rolandoedwards


-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Emi Lu
Sent: Tuesday, February 08, 2011 2:36 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] "select c1, method(c2) group by c1" returns all values of c2 for c1

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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


pgsql-sql by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: "select c1, method(c2) group by c1" returns all values of c2 for c1
Next
From: Peter Steinheuser
Date:
Subject: Re: "select c1, method(c2) group by c1" returns all values of c2 for c1