Calculating product from rows - (aggregate product ) - Mailing list pgsql-general

From Allan Kamau
Subject Calculating product from rows - (aggregate product )
Date
Msg-id 49FEA10E.5090401@sanbi.ac.za
Whole thread Raw
Responses Re: Calculating product from rows - (aggregate product )
Re: Calculating product from rows - (aggregate product )
List pgsql-general
Hi

I would like to calculate a product of a field's values of a relation,
this function may multiply each value and give the result as a single
float number.

For example:


CREATE table imaginary(id INTEGER NOT NULL, some_field FLOAT
NULL,primary key(id));

INSERT INTO imarginary(1,0.333);INSERT INTO imarginary(2,0.667);INSERT
INTO imarginary(3,0.4);


SELECT prod(some_field) FROM imarginary;


would give 0.0888444 (which is 0.333*0.667*0.4)


Is there an already existing function that does this.


Allan.


pgsql-general by date:

Previous
From: Bill Moseley
Date:
Subject: Re: Tracking down a deadlock
Next
From: Allan Kamau
Date:
Subject: Re: Calculating product from rows - (aggregate product )