Search Postgresql Archives

Calculating product from rows - (aggregate product )

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux