From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Calculating product from rows - (aggregate product ) |
Date: | 2009-05-04 22:04:42 |
Message-ID: | 20090504220441.GD26374@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, May 04, 2009 at 10:42:01AM +0200, A. Kretschmer wrote:
> No, you need a own aggregate function, but it is easy:
>
> test=# CREATE FUNCTION multiply_aggregate(float,float) RETURNS float AS
> ' select $1 * $2; ' language sql IMMUTABLE STRICT; CREATE AGGREGATE
> multiply (basetype=float, sfunc=multiply_aggregate, stype=float,
> initcond=1 ) ;
> CREATE FUNCTION
> CREATE AGGREGATE
Note, you don't have to create your own function here, since there's a
builtin called float8mul. So the following will work:
CREATE AGGREGATE multiply (basetype=float8, sfunc=float8mul, stype=float8, initcond=1);
The rest is the same.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-05-04 23:51:39 | Re: Calculating product from rows - (aggregate product ) |
Previous Message | Dennis Brakhane | 2009-05-04 21:28:49 | Re: Calculating product from rows - (aggregate product ) |