X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B6F389DCA22 for ; Sat, 11 Mar 2006 12:58:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99150-04 for ; Sat, 11 Mar 2006 12:58:29 -0400 (AST) X-Greylist: delayed 00:26:52.239846 by SQLgrey- Received: from hosts.rhea.solnet (0x50c60afe.vgnxx3.adsl-dhcp.tele.dk [80.198.10.254]) by postgresql.org (Postfix) with ESMTP id 0C3109DCBEC for ; Sat, 11 Mar 2006 12:58:27 -0400 (AST) Received: from io.solnet (io.solnet [10.1.1.8]) (authenticated bits=0) by hosts.rhea.solnet (8.13.0/8.13.0) with ESMTP id k2BHUJR1016830 for ; Sat, 11 Mar 2006 18:30:19 +0100 Date: Sat, 11 Mar 2006 17:58:26 +0100 From: "Jesper K. Pedersen" To: pgsql-sql@postgresql.org Subject: Re: Merging rows into one result? Message-ID: <20060311175826.2afaf9c5@io.solnet> In-Reply-To: <20060311164337.GA19131@KanotixBox> References: <20060311173133.1358a018@io.solnet> <20060311164337.GA19131@KanotixBox> X-Mailer: Sylpheed-Claws 2.0.0 (GTK+ 2.6.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamd / ClamAV version 0.74, clamav-milter version 0.74a on rhea X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200603/166 X-Sequence-Number: 24512 On Sat, 11 Mar 2006 17:43:37 +0100 Andreas Kretschmer wrote: > Jesper K. Pedersen schrieb: > > > Is it possible to use SQL to merge data into one result? > > > > A theorethical example to explain: > > > > tbl_test ( > > id integer, > > information varchar(25)) > > > > id | information > > ---+-------------- > > 1 | Yo > > 2 | Go away > > 1 | Stay put > > 3 | Greetings > > > > Please note id is not unique and not a primary key. > > > > and I wonder if there is any functions to "merge" data (sort of > > concat'ing). > > A normal: select information from tbl_test where id=1 > > would result in the rows > > Yo > > Stay put > > > > I would like a single row result in the format of: > > Yo Stay put > > Yes, of corse, this is possible. You need a own aggregate-function. A > similar example for this task can you find here: > > http://www.zigo.dhs.org/postgresql/#comma_aggregate > > I think, it is very simple to rewrite this example for your purpose. > The comma aggregate worked like a charm. Thank's