Re: Combining several rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthias Nagl <pg(at)mnagl(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Combining several rows
Date: 2004-05-24 13:49:56
Message-ID: 10852.1085406596@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthias Nagl <pg(at)mnagl(dot)de> writes:
> Let's say I've got a table in the following form:

> SELECT * FROM test;

> id | name
> -----------
> 1 | abc
> 2 | def
> 3 | ghi

> For a table like this I am looking for a query that returns a result that
> looks this way:

> name
> -------------
> abc, def, ghi

The easy way to do this is with a user-defined aggregate. I believe
there are several threads in the mailing list archives that give
solutions to exactly this problem. I tried "create aggregate comma"
at http://www.pgsql.ru/db/pgsearch/ and got this as the first hit:
http://archives.postgresql.org/pgsql-sql/2003-03/msg00381.php

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Spiegelberg 2004-05-24 13:59:56 Re: Clustering Postgres
Previous Message Holger Klawitter 2004-05-24 13:40:20 Re: Combining several rows