Re: Multiple rows into one row - Mailing list pgsql-novice

From A. Kretschmer
Subject Re: Multiple rows into one row
Date
Msg-id 20080202160436.GA32408@a-kretschmer.de
Whole thread Raw
In response to Multiple rows into one row  (Raimon <coder@montx.com>)
Responses Re: Multiple rows into one row
List pgsql-novice
am  Sat, dem 02.02.2008, um 16:13:20 +0100 mailte Raimon folgendes:
> Hello,
>
> I can't find any reference in PostgreSQL documentation, if this is
> possible:
>
> I want to have some rows in one column, with the values separated for
> example by a comma.
>
> SELECT name FROM animals WHERE customer_id = '5'
>
> - cat
> - dog
> - turtle
>
> I would like to have this like this:
>
> - cat, dog, turtle

test=*# select * from animals ;
 id |  name
----+--------
  5 | cat
  5 | dog
  5 | turtle
(3 rows)

test=*# select array_to_string(array(select name from animals where id=5), ', ');
 array_to_string
------------------
 cat, dog, turtle


HTH, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

pgsql-novice by date:

Previous
From: "Mike Ellsworth"
Date:
Subject: Re: Multiple rows into one row
Next
From: "Aílsom F. Heringer"
Date:
Subject: first message: SELECT FROM