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 42CF59DCA39 for ; Sat, 11 Mar 2006 13:03:14 -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 00224-07 for ; Sat, 11 Mar 2006 13:03:12 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 522CF9DCA22 for ; Sat, 11 Mar 2006 13:03:10 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id EA32130927; Sat, 11 Mar 2006 18:03:09 +0100 (MET) From: Christopher Browne X-Newsgroups: pgsql.sql Subject: Re: Merging rows into one result? Date: Sat, 11 Mar 2006 12:00:27 -0500 Organization: cbbrowne Computing Inc Lines: 39 Message-ID: <87wtf0kjbo.fsf@wolfe.cbbrowne.com> References: <20060311173133.1358a018@io.solnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) Cancel-Lock: sha1:s0xqlxVJIoj2rN6YGNwFmfmaJwk= To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.72 required=5 tests=[AWL=-0.093, INFO_TLD=0.813] X-Spam-Score: 0.72 X-Spam-Level: X-Archive-Number: 200603/167 X-Sequence-Number: 24513 Centuries ago, Nostradamus foresaw when jkp@solnet.homeip.net ("Jesper K. Pedersen") would write: > 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 > > Any ideas on this? Sure, you could create a custom aggregate to append them using spaces. Look in the PostgreSQL documentation under "CREATE AGGREGATE." If you check the online version at PostgreSQL.org, there are comments showing examples... -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','gmail.com'). http://linuxdatabases.info/info/wp.html --Despite Pending :Alarm--