Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-17 Thread PFC
I'm just curious - what's the 'OFFSET 0' for? Trick to fool postgres into thinking it can't rewrite out your subquery and eliminate it ... ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-17 Thread Dmitri Bichko
> 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 I'm just curious - what's the 'OFFSET 0' for? Dmitri ---(end of broadcast)--- TIP 5: Have yo

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-12 Thread Greg Stark
Nick Fankhauser <[EMAIL PROTECTED]> writes: > Alvaro Herrera wrote: > > > The order is not really guaranteed, though if this is a one-shot thing, > > you may get away with turning off hashed aggregates. > > > > When I read this, I assumed there was a runtime parameter I could set that was > sim

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-10 Thread PFC
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| r

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-10 Thread Nick Fankhauser
Alvaro Herrera wrote: The order is not really guaranteed, though if this is a one-shot thing, you may get away with turning off hashed aggregates. When I read this, I assumed there was a runtime parameter I could set that was similar to ENABLE_HASHJOIN. Are you referring to a different runtime p

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-08 Thread Nick Fankhauser
Excellent! Thanks for providing both the idea and an example. I didn't get the idea right away, but the example made it clear. I'll try that on my table and report back on how it works out. Regards, -Nick -- Nick Fankhauser

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-08 Thread Alvaro Herrera
On Sun, May 08, 2005 at 01:55:56PM -0500, Nick Fankhauser wrote: > > Hi- I'm doing a conversion from an older database in which a memo field was > handled by storing one line per record and then displaying the related > records in order. I want to compress all of the lines into a single text >

[SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-08 Thread Nick Fankhauser
Hi- I'm doing a conversion from an older database in which a memo field was handled by storing one line per record and then displaying the related records in order. I want to compress all of the lines into a single text field with one record per memo entry. So for instance, the old database look