From: Jesper K. Pedersen <jkp@solnet.homeip.net>
To: pgsql-sql@postgresql.org
Subject: Re: Merging rows into one result?
Date: Sat, 11 Mar 2006 17:58:26 +0100
Message-ID: <20060311175826.2afaf9c5@io.solnet> (raw)
In-Reply-To: <20060311164337.GA19131@KanotixBox>
References: <20060311173133.1358a018@io.solnet>
<20060311164337.GA19131@KanotixBox>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jkp@solnet.homeip.net
Subject: Re: Merging rows into one result?
In-Reply-To: <20060311175826.2afaf9c5@io.solnet>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox