Re: Combining several rows [solved]

From: Matthias Nagl <pg(at)mnagl(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Combining several rows [solved]
Date: 2004-05-24 22:01:42
Message-ID: 200405250001.47761.pg@mnagl.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks a lot Holger your aggregate function is the perfect solution to my
problem.

yours
Matthias Nagl

Am Monday 24 May 2004 15:40 schrieb Holger Klawitter:
> 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAsnDLfg4gS83RRywRAmzWAJ9gzOVDbKsyjxB6tu08lDp6A+bT9wCfZ5QG
HOB3GYN85ldJJcvdH6W5F7I=
=Yw/g
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2004-05-24 23:21:41 Re: Error building PHP with PostgreSQL support
Previous Message Joe Lester 2004-05-24 21:25:30 Abnormal Exit Quandary