From: | "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Concatenate strings using GROUP BY |
Date: | 2006-02-09 09:35:03 |
Message-ID: | 6C0CF58A187DA5479245E0830AF84F42143B77@poweredge.attiksystem.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
Let's say we have a query like:
SELECT id, fk, str
FROM foo
... which returns:
id fk str
---------------
1 1 a
2 1 b
3 2 c
Is there a pure SQL way of contactenating str values into a single string,
and get instead:
id fk str
---------------
1 1 a/b
2 12 c
I was thinking of something like:
SELECT id, fk, CONCAT(str || '/')
FROM FOO
GROUP BY fk
Do we have to use PL/PGSQL for that?
Thanks,
----------------------------------
Philippe Lang, Ing. Dipl. EPFL
Attik System
rte de la Fonderie 2
1700 Fribourg
Switzerland
http://www.attiksystem.ch
Tel: +41 (26) 422 13 75
Fax: +41 (26) 422 13 76
Email: philippe(dot)lang(at)attiksystem(dot)ch
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-02-09 09:52:56 | Re: Concatenate strings using GROUP BY |
Previous Message | Patrick JACQUOT | 2006-02-09 08:59:55 | Re: Non Matching Records in Two Tables |