Re: How to combine many rows into one row (by concatenation?) ?

From: A B <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to combine many rows into one row (by concatenation?) ?
Date: 2010-06-17 15:24:01
Message-ID: AANLkTikjcSnpxknWySJhGwqA9LBbXfkakDaFYnDo8B1O@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I should have added that the "concatenation" of the data to 10 20
or 10 30 or something is not really important how it is done, the
main point is to get only two fields in each row that is returned.

If the result is concatenated would be easiest, but perhaps there are
other ways to combine all the x values?

2010/6/17 A B <gentosaker(at)gmail(dot)com>:
> Hi.
>
> The table is   table foo( id integer, x integer);  and let the data be
> id    x
> =====
> 1     10
> 1     20
> 2     20
> 3     30
> 3     10
>
> Now I would like to get the data in  a format like this
>
> 1 , 10 20
> 2 , 20
> 3 , 10 30
>
> where id is the first field, and the second field is the x values sorted.
>
> Is there a simple way to do this?
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas Kretschmer 2010-06-17 15:25:55 Re: How to combine many rows into one row (by concatenation?) ?
Previous Message Atif Jung 2010-06-17 15:19:20 Re: Runnning operating system commands from an SPL