Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B4B4EB5DBCA for ; Sat, 18 Jun 2011 19:06:07 -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 69870-06 for ; Sat, 18 Jun 2011 22:06:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f46.google.com (mail-pz0-f46.google.com [209.85.210.46]) by mail.postgresql.org (Postfix) with ESMTP id 14F43B5DBBE for ; Sat, 18 Jun 2011 19:06:00 -0300 (ADT) Received: by pzk9 with SMTP id 9so2614411pzk.19 for ; Sat, 18 Jun 2011 15:06:00 -0700 (PDT) Received: by 10.68.17.232 with SMTP id r8mr1634071pbd.91.1308434760294; Sat, 18 Jun 2011 15:06:00 -0700 (PDT) Received: from [10.102.240.24] ([32.153.76.118]) by mx.google.com with ESMTPS id o2sm2263319pbj.17.2011.06.18.15.05.56 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2011 15:05:59 -0700 (PDT) References: <1308356423557-4500306.post@n5.nabble.com> In-Reply-To: <1308356423557-4500306.post@n5.nabble.com> Mime-Version: 1.0 (iPhone Mail 8A306) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: Cc: "pgsql-sql@postgresql.org" X-Mailer: iPhone Mail (8A306) From: Samuel Gendler Subject: Re: Append n Rows into a Single Row Date: Sat, 18 Jun 2011 15:05:58 -0700 To: Tripura 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, MIME_QP_LONG_LINE=0.001, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201106/65 X-Sequence-Number: 35531 Look at the documentation for the tablefunc contrib module. It provides a cr= osstab() function which will allow you to pivot multiple rows into multiple c= olumns in a single row, with all rows that share a particular key in one or m= ore columns pivoting up into the same row, but different keys ending up as s= eparate rows. You could then string concatenate all columns of a single row i= nto a single string if desired, Sent from my iPhone On Jun 17, 2011, at 17:20, Tripura wrote: > Hi, > I am totally new to PostgreSQL and this is my first script. > Can anyone please help me with my following requirement=20 >=20 > 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. >=20 > For example=20 > The current script returns, something like this=20 > Tom > Tad > Max > Ted >=20 > I have to update the existing script to show the above results as follow > Tom || Tad || Max || Ted=20 >=20 > Something like colace in Ms sql >=20 > Any help is really appriciated. >=20 > Thankyou in Advance. >=20 >=20 >=20 >=20 >=20 >=20 >=20 > -- > View this message in context: http://postgresql.1045698.n5.nabble.com/Appe= nd-n-Rows-into-a-Single-Row-tp4500306p4500306.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql