| From: | PFC <lists(at)boutiquenumerique(dot)com> |
|---|---|
| To: | nickf(at)doxpop(dot)com, pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: interesting SQL puzzle - concatenating column with itself. |
| Date: | 2005-05-10 20:45:38 |
| Message-ID: | op.sqkumco8th1vuj@localhost |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 !
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dmitri Bichko | 2005-05-10 21:53:59 | Re: interesting SQL puzzle - concatenating column with itself. |
| Previous Message | Nick Fankhauser | 2005-05-10 19:56:35 | Re: interesting SQL puzzle - concatenating column with itself. |