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

From Raimon
Subject Re: Multiple rows into one row
Date
Msg-id 52BF50D9-D560-476A-B6D6-7842E9B11309@montx.com
Whole thread Raw
In response to Re: Multiple rows into one row  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List pgsql-novice
thanks !

r.


On 02/02/2008, at 17:04, A. Kretschmer wrote:

> 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
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>



pgsql-novice by date:

Previous
From: Raimon
Date:
Subject: Re: Multiple rows into one row
Next
From: "Didier Gasser-Morlay"
Date:
Subject: Where clause...