Re: Multiple rows into one row

From: "Mike Ellsworth" <younicycle(at)gmail(dot)com>
To: Raimon <coder(at)montx(dot)com>
Cc: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Multiple rows into one row
Date: 2008-02-02 15:54:26
Message-ID: 219951fd0802020754r28b0cf3bpd31e378dc1c38ef@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Feb 2, 2008 10:13 AM, Raimon <coder(at)montx(dot)com> wrote:
> 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
>
>
> So I could issue a SELECT like this:
>
> SELECT customer.name, (SELECT name FROM animals WHERE customer_id =
> customer.id) AS animals FROM customer
>
> name animals
> ------- -----------
> Peter dog,cat
> Lisa turtle
> Anthony bird,elephant
>
> I could find info about PIVOT and some other extra functionalities
> from other databases like Oracle, SQL server, ...
>

I think, here: http://www.postgresql.org/docs/8.3/static/tablefunc.html

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2008-02-02 16:04:36 Re: Multiple rows into one row
Previous Message Raimon 2008-02-02 15:13:20 Multiple rows into one row