Received: from www-uk-05.digiserve.com ([195.97.231.11]) by mail.postgresql.org (8.11.3/8.11.1) with ESMTP id f2MF4Nt74574 for ; Thu, 22 Mar 2001 10:04:23 -0500 (EST) (envelope-from dev@archonet.com) Received: from mainbox.archonet.com (mwynhau.demon.co.uk [193.237.186.96]) by www-uk-05.digiserve.com (8.9.1/8.9.1) with ESMTP id PAA21119; Thu, 22 Mar 2001 15:05:14 GMT Received: from client (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with SMTP id AC3BB2A687; Thu, 22 Mar 2001 14:42:15 +0000 (GMT) Message-ID: <002501c0b2de$48e19100$1001a8c0@archonet.com> From: "Richard Huxton" To: , References: Subject: Re: how to build this string ? Date: Thu, 22 Mar 2001 14:42:12 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200103/448 X-Sequence-Number: 2116 From: > Hello there Hello again Juerg - I take it you got that monster query working after? > Is it possible (and I think it is) to do the following : > > I have a table with diameters and types. I need to build a comma separated > string. > > typ diam > 01 800 > 01 840 > 01 870 > 01 1120 > > select diam from zylinder where typ='01' > > should produce the string "800,840,870,1120" You'll want to build yourself a custom aggregate function. Check the mail archives for someone else who did this recently (in the last month or so, Tom Lane was involved in the discussion too). I forget the fella's name, but he should have almost exactly what you want. You can then do something like: select typ, commify(diam) from zylinder group by typ; - Richard Huxton