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 122459DC84C for ; Sat, 11 Mar 2006 12:42:32 -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 95041-09 for ; Sat, 11 Mar 2006 12:42:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 8FF0C9DC821 for ; Sat, 11 Mar 2006 12:42:28 -0400 (AST) Received: from a-kretschmer.de (p54B3C0C8.dip0.t-ipconnect.de [84.179.192.200]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id k2BGgPBI001793 for ; Sat, 11 Mar 2006 17:42:26 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.60) (envelope-from ) id 1FI7Bp-0007v1-To for pgsql-sql@postgresql.org; Sat, 11 Mar 2006 17:43:37 +0100 Date: Sat, 11 Mar 2006 17:43:37 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: Merging rows into one result? Message-ID: <20060311164337.GA19131@KanotixBox> References: <20060311173133.1358a018@io.solnet> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20060311173133.1358a018@io.solnet> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] X-Spam-Score: 0.123 X-Spam-Level: X-Archive-Number: 200603/164 X-Sequence-Number: 24510 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. HTH, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°