On Tuesday 16 Jul 2002 9:09 am, Marcus Claesson wrote:
> I have a table like this:
> SELECT * FROM old_tab;
> id | descr
> -------------------
> 3 | ddd
> 3 | ddd
> 3 | eee
> 3 | fff
> SELECT * FROM new_tab;
> id | descr
> --------------------------
> 1 | aaa;bbb
> 2 | ccc;bbb
> 3 | ddd;eee;fff
> 4 | bbb
You'll want to write your own aggregate function - something like max() which
will work over a range of values. This is easier than you might think.
The only thing to be careful of is that order isn't guaranteed, so by default
you could have "ddd;eee;fff" or "fff;ddd;eee" etc.
Go to techdocs.postgresql.org and check the "Postgresql Cookbook" courtesy of
Roberto Mello and also the "Postgresql Notes" by me. Also check the online
manual and the mailing archives (try searching on "aggregate" and "catenate"
or "concat").
HTH
- Richard Huxton