From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to count the number of items in an Array? |
Date: | 2010-02-21 15:25:15 |
Message-ID: | 20100221152515.GA23753@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Andre Lopes <lopes80andre(at)gmail(dot)com> wrote:
> One more time, thanks for the reply. I'am using postgre 8.3. I think I don't
> have the array_agg(), there is another way of doing it?
Sure.
The doc contains an example for a user-defined aggregate-function:
http://www.postgresql.org/docs/8.4/interactive/xaggr.html
It works with versions prior 8.4.
test=*# CREATE AGGREGATE array_accum (anyelement)
test-# (
test(# sfunc = array_append,
test(# stype = anyarray,
test(# initcond = '{}'
test(# );
CREATE AGGREGATE
Zeit: 44,645 ms
test=*# select array_accum(a) from foo;
array_accum
-------------
{1,3,5,7}
(1 Zeile)
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
From | Date | Subject | |
---|---|---|---|
Next Message | Andre Lopes | 2010-02-21 15:46:18 | Re: How to count the number of items in an Array? |
Previous Message | Andre Lopes | 2010-02-21 15:17:26 | Re: How to count the number of items in an Array? |