pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: nickf@doxpop.com
To: pgsql-sql@postgresql.org
Subject: Re: interesting SQL puzzle - concatenating column with itself.
Date: Tue, 10 May 2005 22:45:38 +0200
Message-ID: <op.sqkumco8th1vuj@localhost> (raw)
In-Reply-To: <427E60BC.8060701@ontko.com>
References: <427E60BC.8060701@ontko.com>


> 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 !




view thread (8+ messages)  latest in thread

Message-ID: <op.sqkumco8th1vuj@localhost>
Permalink:  ../op.sqkumco8th1vuj@localhost/
Also on:    postgresql.org/message-id/op.sqkumco8th1vuj@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@boutiquenumerique.com, nickf@doxpop.com
  Subject: Re: interesting SQL puzzle - concatenating column with itself.
  In-Reply-To: <op.sqkumco8th1vuj@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox