Re: interesting SQL puzzle - concatenating column with itself. - Mailing list pgsql-sql

From PFC
Subject Re: interesting SQL puzzle - concatenating column with itself.
Date
Msg-id op.sqkumco8th1vuj@localhost
Whole thread Raw
In response to interesting SQL puzzle - concatenating column with itself.  (Nick Fankhauser <nickf@ontko.com>)
List 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 by date:

Previous
From: Nick Fankhauser
Date:
Subject: Re: interesting SQL puzzle - concatenating column with itself.
Next
From: subhash@nmsu.edu
Date:
Subject: md5 in pg_shadow?