tags:

views:

202

answers:

3

I'm having a first painful experience with postgresql, and the minute-challenge of the moment is :

How to perform a concat_ws in postgresql, to join several fields value from a group by :

select concat_ws(';',field_lambda) from table_lambda group by id;
A: 

Other StackOverflow question regarding custom PostgreSQL custom Concat() functions might be of help to you.

Diakonia7
+1  A: 

For Postgres >= 8.4:

select ARRAY_TO_STRING(ARRAY_AGG(field_lambda),';') from table_lambda group by id;
Milen A. Radev
Thanks, that works.
Gzorg
A: 

Without array_agg (before 8.4), you can use:

SELECT array_to_string(ARRAY(SELECT field_lambda FROM table_lambda GROUP BY id), ';');
Daniel Vérité