From: Pavel Stehule <pavel.stehule@gmail.com>
To: Marcin Krawczyk <jankes.mk@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: aggregate reverse
Date: Fri, 1 Feb 2008 18:33:54 +0100
Message-ID: <162867790802010933m4f3e2808w405590b26d31d402@mail.gmail.com> (raw)
In-Reply-To: <95f6bf9b0802010724u5aa9b48x188af97410237d7@mail.gmail.com>
References: <95f6bf9b0802010724u5aa9b48x188af97410237d7@mail.gmail.com>
Hello
I am not sure if I understand well.
On 01/02/2008, Marcin Krawczyk <jankes.mk@gmail.com> wrote:
> Hi all. I wolud like to know whether it is possible to reverse the behaviour
> of an aggregate? Say I have a string '1,2,3,4'. Is there a way to split
> those values to records?
create or replace function unpack(anyarray)
returns setof anyelement as $$
select $1[i]
from generate_series(array_lower($1,1), array_upper($1,1)) g(i)
$$ language sql immutable;
select * from unpack(string_to_array('1,2,3,4',','));
unpack
--------
1
2
3
4
(4 rows)
Regards
Pavel
>
> Regards and thanks in advance.
> mk
>
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: pavel.stehule@gmail.com, jankes.mk@gmail.com
Subject: Re: aggregate reverse
In-Reply-To: <162867790802010933m4f3e2808w405590b26d31d402@mail.gmail.com>
* 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