From: Tomasz Myrta <jasiek@klaster.net>
To: Kumar <sgnerd@yahoo.com.sg>
Cc: psql <pgsql-sql@postgresql.org>
Subject: Re: Concatenating multiple fetches into a single string
Date: Tue, 02 Dec 2003 07:07:42 +0100
Message-ID: <3FCC2C2E.2050106@klaster.net> (raw)
In-Reply-To: <00cc01c3b88f$f14f3540$7502a8c0@hdsc.com>
References: <024a01c3b802$d9afac40$7502a8c0@hdsc.com>
<3FCB9E01.6010405@klaster.net>
<00cc01c3b88f$f14f3540$7502a8c0@hdsc.com>
Dnia 2003-12-02 05:51, Użytkownik Kumar napisał:
> Thanks for your reply.
>
> But how to use this comma_aggregate( ) function to concatenate the fetched
> columns values from a select statement. In my example my select stmt fetches
> the following 3 rows. How can I use this function to concatenate them.
>
> Select full_name FROM project_members where project_members.project_role_id
> in ( ' x,y,z ') ;
>
> full_name
> ---------------
> David
> Postgres
> plpgsql
>
> Expected return string is - 'David,Postgres,Plsql'
Where is the problem?
It's an aggregate function - you use it like the other ones:
select comma(full_name) from...
There is one problem with this function - strings order is unexpectable,
but you can always sort them in subselect before using this function:
select comma(full_name) from
(select full_name from .... order by full_name) X;
Regards,
Tomasz Myrta
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: jasiek@klaster.net, sgnerd@yahoo.com.sg
Subject: Re: Concatenating multiple fetches into a single string
In-Reply-To: <3FCC2C2E.2050106@klaster.net>
* 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