Re: how to build this string ?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: how to build this string ?
Дата
Msg-id 002501c0b2de$48e19100$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на how to build this string ?  (juerg.rietmann@pup.ch)
Список pgsql-sql
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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Antti Linno
Дата:
Сообщение: Birthday search.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: CHAR or VARCHAR