Re: Merging rows into one result? - Mailing list pgsql-sql

From Jesper K. Pedersen
Subject Re: Merging rows into one result?
Date
Msg-id 20060311175826.2afaf9c5@io.solnet
Whole thread Raw
In response to Re: Merging rows into one result?  (Andreas Kretschmer <akretschmer@spamfence.net>)
List pgsql-sql
On Sat, 11 Mar 2006 17:43:37 +0100
Andreas Kretschmer <akretschmer@spamfence.net> wrote:

> Jesper K. Pedersen <jkp@solnet.homeip.net> schrieb:
> 
> > Is it possible to use SQL to merge data into one result?
> > 
> > A theorethical example to explain:
> > 
> > tbl_test (
> >   id integer,
> >   information varchar(25))
> > 
> > id | information
> > ---+--------------
> > 1  | Yo
> > 2  | Go away
> > 1  | Stay put
> > 3  | Greetings
> > 
> > Please note id is not unique and not a primary key.
> > 
> > and I wonder if there is any functions to "merge" data (sort of
> > concat'ing).
> > A normal: select information from tbl_test where id=1
> > would result in the rows
> >  Yo
> >  Stay put
> > 
> > I would like a single row result in the format of:
> >  Yo Stay put
> 
> Yes, of corse, this is possible. You need a own aggregate-function. A
> similar example for this task can you find here:
> 
> http://www.zigo.dhs.org/postgresql/#comma_aggregate
> 
> I think, it is very simple to rewrite this example for your purpose.
> 
The comma aggregate worked like a charm.

Thank's


pgsql-sql by date:

Previous
From: Volkan YAZICI
Date:
Subject: Re: Merging rows into one result?
Next
From: Christopher Browne
Date:
Subject: Re: Merging rows into one result?