Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5F434B5DBC0 for ; Sun, 19 Jun 2011 00:52:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 18332-07 for ; Sun, 19 Jun 2011 03:51:57 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id 97EC3B5D801 for ; Sun, 19 Jun 2011 00:51:56 -0300 (ADT) Received: by pvg12 with SMTP id 12so2763826pvg.19 for ; Sat, 18 Jun 2011 20:51:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.6.65 with SMTP id y1mr1682531pby.163.1308455515583; Sat, 18 Jun 2011 20:51:55 -0700 (PDT) Received: by 10.68.49.197 with HTTP; Sat, 18 Jun 2011 20:51:55 -0700 (PDT) X-Originating-IP: [66.215.95.51] In-Reply-To: <4DFD6E22.1090700@gmail.com> References: <1308356423557-4500306.post@n5.nabble.com> <4DFD6E22.1090700@gmail.com> Date: Sat, 18 Jun 2011 20:51:55 -0700 Message-ID: Subject: Re: Append n Rows into a Single Row From: Samuel Gendler To: Rob Sargent Cc: Tripura , pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=bcaec53041ef35f4bd04a6088a06 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.777 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201106/67 X-Sequence-Number: 35533 --bcaec53041ef35f4bd04a6088a06 Content-Type: text/plain; charset=ISO-8859-1 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 --sam On Sat, Jun 18, 2011 at 8:33 PM, Rob Sargent wrote: > Look at the array aggregation functions here docs/9.0/static/functions-**array.html > > > > > Tripura wrote: > >> Hi, >> I am totally new to PostgreSQL and this is my first script. >> Can anyone please help me with my following requirement >> I have script that returns 1 column and 40 rows. >> My requirement is update this existing script to show all the 40 rows data >> in a single row as a string. >> >> For example The current script returns, something like this Tom >> Tad >> Max >> Ted >> >> I have to update the existing script to show the above results as follow >> Tom || Tad || Max || Ted >> Something like colace in Ms sql >> >> Any help is really appriciated. >> >> Thankyou in Advance. >> >> >> >> >> >> >> >> -- >> View this message in context: http://postgresql.1045698.n5.** >> nabble.com/Append-n-Rows-into-**a-Single-Row-**tp4500306p4500306.html >> Sent from the PostgreSQL - sql mailing list archive at Nabble.com. >> >> >> > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/**mailpref/pgsql-sql > --bcaec53041ef35f4bd04a6088a06 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Actually, you need the array_agg() function to aggregate multiple rows into= a single array, and that is discussed on the aggregate functions page, her= e:=A0http://www.postgresql.org/docs/9.0/static/functions-aggregate.html=

You could then use one of the other array functions to manip= ulate that array.

But given that you are appending s= trings 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. =A0It looks like th= at function isn't available before 9.0

--sam



On Sat, Jun 18, 2011 at 8:33 PM, Rob Sargent &= lt;robjsargent@gmail.com> wrote:
Look at the array aggregation functions her= e <http://www.postgresql.org/docs/9.0/static/fu= nctions-array.html>


Tripura wrote:
Hi,
I am totally new to PostgreSQL and this is my first script.
Can anyone please help me with my following requirement
I have script that returns =A01 column and 40 rows.
My requirement is update this existing script to show all the 40 rows data<= br> in a single row as a string.

For example The current script returns, something like this Tom
Tad
Max
Ted

I have to update the existing script to show the above results as follow Tom || Tad || Max || Ted
Something like colace in Ms sql

Any help is really appriciated.

Thankyou in Advance.







--
View this message in context: http://postgresql.1045698.n5.nabble.com/Append-n-Rows-into-<= /u>a-Single-Row-tp4500306p4500306.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

=A0

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
= http://www.postgresql.org/mailpref/pgsql-sql

--bcaec53041ef35f4bd04a6088a06--