X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C3D4ED1B4A7 for ; Tue, 2 Dec 2003 06:07:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 57119-09 for ; Tue, 2 Dec 2003 02:07:12 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id DC2A7D1B4B7 for ; Tue, 2 Dec 2003 02:07:11 -0400 (AST) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id C0B812B400; Tue, 2 Dec 2003 07:07:10 +0100 (CET) Message-ID: <3FCC2C2E.2050106@klaster.net> Date: Tue, 02 Dec 2003 07:07:42 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5) Gecko/20031007 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Kumar Cc: psql Subject: Re: Concatenating multiple fetches into a single string References: <024a01c3b802$d9afac40$7502a8c0@hdsc.com> <3FCB9E01.6010405@klaster.net> <00cc01c3b88f$f14f3540$7502a8c0@hdsc.com> In-Reply-To: <00cc01c3b88f$f14f3540$7502a8c0@hdsc.com> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/9 X-Sequence-Number: 16175 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