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

From Peter Steinheuser
Subject Re: "select c1, method(c2) group by c1" returns all values of c2 for c1
Date
Msg-id AANLkTikuf1u-V8f1T9Qp5pk5xMnLZRBom9SwY-FZRRMx@mail.gmail.com
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>)
List pgsql-sql
I'm not saying this is good or best but:<br /><br />select distinct a.c1, array_to_string(array(select c2 from t1 as b
whereb.c1 = a.c1),',')<br />     from t1 as a;<br /> c1 | array_to_string <br />----+-----------------<br />   1 |
val1,val2,val3<br/>  2 | val1<br />  3 | val5,val6<br />(3 rows)<br /><br /><br /><div class="gmail_quote">On Tue, Feb
8,2011 at 2:35 PM, Emi Lu <span dir="ltr"><<a
href="mailto:emilu@encs.concordia.ca">emilu@encs.concordia.ca</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="margin:0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Good afternoon,<br
/><br/> Is there a method to retrieve the following results:<br /><br /> T1(c1 int, c2 varchar(128) )<br />
---------------------------------<br/><br /><br /> (1, val1);<br /> (1, val2);<br /> (1, val3);<br /> (2, val1);<br />
(3,val5);<br /> (3, val6);<br /><br /> select c1, method(c2)<br /> group by c1<br /><br /> returns:<br />
============<br/> 1,   "val1, val2, val3"<br /> 2,   "val1"<br /> 3,   "val5, val6"<br /><br /><br /> Thanks a lot!<br
/><br/> --<br /> Lu Ying<br /><font color="#888888"><br /> -- <br /> Sent via pgsql-sql mailing list (<a
href="mailto:pgsql-sql@postgresql.org"target="_blank">pgsql-sql@postgresql.org</a>)<br /> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br/></font></blockquote></div><br /><br clear="all"
/><br/>-- <br />Peter Steinheuser<br /><a href="mailto:psteinheuser@myyearbook.com">psteinheuser@myyearbook.com</a><br
/>

pgsql-sql by date:

Previous
From: Rolando Edwards
Date:
Subject: Re: "select c1, method(c2) group by c1" returns all values of c2 for c1
Next
From: Emi Lu
Date:
Subject: Re: "select c1, method(c2) group by c1" returns all values of c2 for c1