Skip site navigation (1) Skip section navigation (2)

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: How to combine many rows into one row (by concatenation?) ?
Date: 2010-06-17 15:14:24
Message-ID: AANLkTimM8gYTu9diccGMslOZuQB585DQRO4q-ENCmH_9@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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?

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2010-06-17 15:15:32
Subject: Re: Runnning operating system commands from an SPL
Previous:From: Andreas KretschmerDate: 2010-06-17 14:51:42
Subject: Re: Runnning operating system commands from an SPL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group