Re: Append n Rows into a Single Row

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
Cc: Rob Sargent <robjsargent(at)gmail(dot)com>, Tripura <k_tripura(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Append n Rows into a Single Row
Date: 2011-06-20 17:05:57
Message-ID: 20110620170557.GC16364@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)rice(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas 2011-06-21 01:55:50 problem with selecting from a function
Previous Message Cstdenis 2011-06-20 15:04:47 Query to select nested comments sorted by nesting and date