Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A8C78B5DBE3 for ; Mon, 20 Jun 2011 14:06:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 99602-02 for ; Mon, 20 Jun 2011 17:06:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cooker.cnx.rice.edu (cooker.cnx.rice.edu [168.7.5.70]) by mail.postgresql.org (Postfix) with ESMTP id DDF79B5D94C for ; Mon, 20 Jun 2011 14:06:00 -0300 (ADT) Received: from reedstrm by cooker.cnx.rice.edu with local (Exim 4.72) (envelope-from ) id 1QYhvC-0000bQ-1o; Mon, 20 Jun 2011 12:05:58 -0500 Date: Mon, 20 Jun 2011 12:05:57 -0500 From: "Ross J. Reedstrom" To: Samuel Gendler Cc: Rob Sargent , Tripura , pgsql-sql@postgresql.org Subject: Re: Append n Rows into a Single Row Message-ID: <20110620170557.GC16364@rice.edu> References: <1308356423557-4500306.post@n5.nabble.com> <4DFD6E22.1090700@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/71 X-Sequence-Number: 35537 On Sat, Jun 18, 2011 at 08:51:55PM -0700, Samuel Gendler wrote: > Actually, you need the array_agg() function to aggregate multiple rows into > a single array, and that is discussed on the aggregate functions page, > here: http://www.postgresql.org/docs/9.0/static/functions-aggregate.html > > You could then use one of the other array functions to manipulate that > array. > > But given that you are appending strings to each other in your example, you > can also just use the string_agg function from that same page - assuming you > are on 9.0. It looks like that function isn't available before 9.0 > Nice blog post about this here: http://www.postgresonline.com/journal/archives/191-stringagg.html Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Systems Engineer & Admin, Research Scientist phone: 713-348-6166 Connexions http://cnx.org fax: 713-348-3665 Rice University MS-375, Houston, TX 77005 GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE