Re: interesting SQL puzzle - concatenating column with itself.

Поиск
Список
Период
Сортировка
От PFC
Тема Re: interesting SQL puzzle - concatenating column with itself.
Дата
Msg-id op.sqkumco8th1vuj@localhost
обсуждение исходный текст
Ответ на interesting SQL puzzle - concatenating column with itself.  (Nick Fankhauser <nickf@ontko.com>)
Список pgsql-sql
> 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 !



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

Предыдущее
От: Nick Fankhauser
Дата:
Сообщение: Re: interesting SQL puzzle - concatenating column with itself.
Следующее
От: subhash@nmsu.edu
Дата:
Сообщение: md5 in pg_shadow?