X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B42785424A for ; Tue, 10 May 2005 17:45:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61775-07 for ; Tue, 10 May 2005 20:45:38 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8152E541FC for ; Tue, 10 May 2005 17:45:36 -0300 (ADT) Received: (qmail 19685 invoked from network); 10 May 2005 22:46:00 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 10 May 2005 22:46:00 +0200 To: nickf@doxpop.com, pgsql-sql@postgresql.org Subject: Re: interesting SQL puzzle - concatenating column with itself. References: <427E60BC.8060701@ontko.com> Message-ID: From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Tue, 10 May 2005 22:45:38 +0200 In-Reply-To: <427E60BC.8060701@ontko.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/94 X-Sequence-Number: 21407 > BTW the concatenation function you suggest works nicely except that as > you noted, it concatenates in an unpredictable order, so I'm now trying > to solve that problem. memo_id | sequence | memo_text --------------------------------------- 666 | 1 | The quick 666 | 2 | red fox 666 | 3 | jumped over 666 | 4 | the lazy brown dog You have : SELECT your_concat( memo_text ) FROM table GROUP BY memo_id You can use : SELECT your_concat( memo_text ) FROM (SELECT memo_id, sequence, memo_text FROM table ORDER BY memo_id, sequence OFFSET 0) AS foo GROUP BY memo_id the OFFSET 0 may be necessary (or not). Try it !