From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Concatenate strings using GROUP BY
Date: Thu, 9 Feb 2006 10:52:56 +0100
Message-ID: <20060209095256.GD2458@webserv.wug-glas.de> (raw)
In-Reply-To: <6C0CF58A187DA5479245E0830AF84F42143B77@poweredge.attiksystem.ch>
References: <6C0CF58A187DA5479245E0830AF84F42143B77@poweredge.attiksystem.ch>
am 09.02.2006, um 10:35:03 +0100 mailte Philippe Lang folgendes:
> 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?
Yes, you need a new aggregate function.
http://www.postgresql.org/docs/8.0/interactive/xaggr.html
HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
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: andreas.kretschmer@schollglas.com
Subject: Re: Concatenate strings using GROUP BY
In-Reply-To: <20060209095256.GD2458@webserv.wug-glas.de>
* 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