From: | Tomasz Myrta <jasiek(at)klaster(dot)net> |
---|---|
To: | Kumar <sgnerd(at)yahoo(dot)com(dot)sg> |
Cc: | psql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Concatenating multiple fetches into a single string |
Date: | 2003-12-02 06:07:42 |
Message-ID: | 3FCC2C2E.2050106@klaster.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2003-12-02 08:56:05 | Re: Problem with intervals |
Previous Message | Bob Smith | 2003-12-02 05:09:20 | Problem with intervals |