Lists: | pgsql-hackers |
---|
From: | "David M(dot) Kaplan" <dmkaplan(at)ucdavis(dot)edu> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | aggregate that returns array |
Date: | 2002-07-02 01:25:18 |
Message-ID: | 3D2100FE.8000507@ucdavis.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
Has anyone considered creating an aggregate function that returns an
array of all matching rows? I am not sure if this makes much sense from
a speed point of view or is possible, but it would help denormalizing
tables when necessary. For example, consider a table that looks as follows:
SELECT * FROM t;
id | value
----+-------
1 | 1.5
1 | 2.5
1 | 3.5
2 | 4.5
2 | 5.5
(5 rows)
It would be nice to be able to do a query as follows:
SELECT id, agg_array(value) FROM t GROUP BY id;
id | agg_array
----+-----
1 | {1.5,2.5,3.5}
2 | {4.5,5.5}
(2 rows)
Thanks,
David Kaplan
From: | Hannu Krosing <hannu(at)tm(dot)ee> |
---|---|
To: | "David M(dot) Kaplan" <dmkaplan(at)ucdavis(dot)edu> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: aggregate that returns array |
Date: | 2002-07-02 08:40:46 |
Message-ID: | 1025599246.6928.0.camel@taru.tm.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, 2002-07-02 at 03:25, David M. Kaplan wrote:
> Hi,
>
> Has anyone considered creating an aggregate function that returns an
> array of all matching rows?
check contrib/intagg for a function that does it for integers.
-----------
Hannu