Pages

Thursday, March 6, 2014

How to multiply columns in sql



Temp is a table containing number as column name and if you want to multiply all the values in number column..then simply run the following command.

Select exp(sum(ln(number))) from Temp;


Example:
Number
1
2
3


exp(sum(ln(Number))) = exp(ln1+ln2+ln3) = exp(ln(1*2*3)) = 1*2*3 = 6