Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D6FE31337B83 for ; Tue, 8 Feb 2011 15:44:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 01079-05 for ; Tue, 8 Feb 2011 19:44:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by mail.postgresql.org (Postfix) with ESMTP id 348791337BC2 for ; Tue, 8 Feb 2011 15:44:00 -0400 (AST) Received: by qwa26 with SMTP id 26so4470831qwa.19 for ; Tue, 08 Feb 2011 11:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=BG8gEJRk59pTZorn/xhvhrs9F9HgDkhl9Sy+BYptb6k=; b=XEILqc8q1jO4zlADbuoEKZFNMVWKQH/TN0yjjQjZ+jTWsOthTt/6/JxJLjK0QMoKr3 iDFxBNdw9BUKoan0pJixA1TDC6afUtT/H7VhouHPoazeTI06ddMQdNSW0bPZJaSO1B6t ecDSCDL9vmaO7I2fJhreXQaAtMxXOxDSvXJSI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=sFHfL4a/rjBWLe5+BftxAQQFnUitJqoz0csgU0hX5coR5956nSCtZRBaVTY8fvj8XW HURrIybBbwLtvWiTY0YiPXp3sTtD0bUuE7vWVSawUDiqvAoLU6mcxS4B2ywG/2B5tOjj PET96LHOOFlPMt1f+hDn3nKyLVR4fY7LA6iUs= Received: by 10.229.215.9 with SMTP id hc9mr12490684qcb.117.1297194239575; Tue, 08 Feb 2011 11:43:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.181.198 with HTTP; Tue, 8 Feb 2011 11:43:19 -0800 (PST) In-Reply-To: <4D519B0A.9040708@encs.concordia.ca> References: <4D519B0A.9040708@encs.concordia.ca> From: Pavel Stehule Date: Tue, 8 Feb 2011 20:43:19 +0100 Message-ID: Subject: Re: "select c1, method(c2) group by c1" returns all values of c2 for c1 To: emilu@encs.concordia.ca Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.589 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201102/38 X-Sequence-Number: 35114 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 : > 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: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 1, =C2=A0 "val1, val2, val3" > 2, =C2=A0 "val1" > 3, =C2=A0 "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 >