interesting SQL puzzle - concatenating column with itself.

Поиск
Список
Период
Сортировка
От Nick Fankhauser
Тема interesting SQL puzzle - concatenating column with itself.
Дата
Msg-id 427E60BC.8060701@ontko.com
обсуждение исходный текст
Ответы Re: interesting SQL puzzle - concatenating column with itself.
Re: interesting SQL puzzle - concatenating column with itself.
Список pgsql-sql
Hi- I'm doing a conversion from an older database in which a memo field was handled by storing one line per record and
thendisplaying the related records in order. I want to compress all of the lines into a single text field with one
recordper 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-SQLsolution 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
 



В списке pgsql-sql по дате отправления:

Предыдущее
От: Aarni Ruuhimäki
Дата:
Сообщение: Re: encoding
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: interesting SQL puzzle - concatenating column with itself.