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 243DC53859 for ; Sun, 8 May 2005 15:56:11 -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 50698-03 for ; Sun, 8 May 2005 18:56:08 +0000 (GMT) Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) by svr1.postgresql.org (Postfix) with ESMTP id 53A715379D for ; Sun, 8 May 2005 15:56:07 -0300 (ADT) Received: from [127.0.0.1] (waymoot.ontko.com [199.164.165.31]) by shire.ontko.com (8.12.3/8.12.3/Debian-7.1) with ESMTP id j48Iu4Xw010282 for ; Sun, 8 May 2005 13:56:08 -0500 Message-ID: <427E60BC.8060701@ontko.com> Date: Sun, 08 May 2005 13:55:56 -0500 From: Nick Fankhauser Reply-To: nickf@doxpop.com Organization: Ray Ontko & Co. User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: interesting SQL puzzle - concatenating column with itself. Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/84 X-Sequence-Number: 21397 Hi- I'm doing a conversion from an older database in which a memo field was handled by storing one line per record and then displaying the related records in order. I want to compress all of the lines into a single text field with one record per memo entry. So for instance, the old database looks like this: memo_id | sequence | memo_text --------------------------------------- 666 | 1 | The quick 666 | 2 | red fox 666 | 3 | jumped over 666 | 4 | the lazy brown dog And my goal is to transform each group of lines into a single record that looks like this: memo_id | memo_text ---------------------------------------------------------- 666 | The quick red fox jumped over the lazy brown dog Any thoughts on how to do this via sql? I could write a little program to do it, but it seems like there must be a pure-SQL solution that I'm not seeing. Thanks -Nick -- ------------------------------------------------------------------ Nick Fankhauser nickf@ontko.com Phone 765.935.4283 Fax 765.962.9788 Ray Ontko & Co. - Software Consulting Services http://www.ontko.com