From: | Holger Klawitter <lists(at)klawitter(dot)de> |
---|---|
To: | Matthias Nagl <pg(at)mnagl(dot)de>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Combining several rows |
Date: | 2004-05-24 13:40:20 |
Message-ID: | 200405241539.28011.lists@klawitter.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
> I would like to combine the contents of several rows of a subquery. After
> several hours of search in the documentation and the internet I didn'T find
> a solution and hope anyone can help. My problem:
You have to create your own aggreate.
You can use this one:
- ---------------------------------------------------
CREATE OR REPLACE FUNCTION
join_sep ( text, text, text )
RETURNS text
LANGUAGE 'sql'
IMMUTABLE
AS '
SELECT CASE
WHEN $1 IS NULL THEN $3
ELSE $1 || $2 || $3
END;
';
- ---------------------------------------------------
CREATE OR REPLACE FUNCTION
join_text ( text, text )
RETURNS text
LANGUAGE 'sql'
AS '
SELECT join_sep($1,'', '',$2);
';
- ---------------------------------------------------
CREATE AGGREGATE join (
BASETYPE = text,
SFUNC = join_text,
STYPE = text
);
Mit freundlichem Gruß / With kind regards
Holger Klawitter
- --
lists <at> klawitter <dot> de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQFAsftE1Xdt0HKSwgYRAg/TAJ4rgGwjPVSwrudQ51NP8Imrw0OWhwCfUnMH
h/WlRt3eeNopOtDHYlslnw4=
=xA3Q
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-05-24 13:49:56 | Re: Combining several rows |
Previous Message | Liza | 2004-05-24 13:16:11 | Re: PG_HBA.conf still keeps complaining. I've done all I could imagine. |