pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: pgsql-sql@postgresql.org
To: juerg.rietmann@pup.ch
Subject: Re: how to build this string ?
Date: Thu, 22 Mar 2001 14:42:12 -0000
Message-ID: <002501c0b2de$48e19100$1001a8c0@archonet.com> (raw)
References: <OF7B053C23.2FB4CC76-ONC1256A17.004D03B9@pup.ch>

From: <juerg.rietmann@pup.ch>

> 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




view thread (2+ messages)

Message-ID: <002501c0b2de$48e19100$1001a8c0@archonet.com>
Permalink:  ../002501c0b2de$48e19100$1001a8c0@archonet.com/
Also on:    postgresql.org/message-id/002501c0b2de$48e19100$1001a8c0@archonet.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, juerg.rietmann@pup.ch
  Subject: Re: how to build this string ?
  In-Reply-To: <002501c0b2de$48e19100$1001a8c0@archonet.com>
  References: <OF7B053C23.2FB4CC76-ONC1256A17.004D03B9@pup.ch> <002501c0b2de$48e19100$1001a8c0@archonet.com>

* 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