说一个例子
我有员工表id,name,salary
id |name|salary
1 |raj |50.00
2 |raaj|60.00
3 |nera|555.55
我想将薪水字段50*60*555.55=1666650.00
salary
------
1666650.00
答案 0 :(得分:2)
如果你想要
,我想你想要所有薪水栏的总和select sum(salary)as salary from employee
如果你想要产品那么它就是
select round(EXP(SUM(LOG(salary))),2) as salary from employee
请参阅mysql中不同舍入的示例
SELECT ROUND( 1 ); /* = 1 */
SELECT ROUND( 1.4 ); /* = 1 */
SELECT ROUND( 1.5 ); /* = 2 */
SELECT ROUND( -1.4 ); /* = -1 */
SELECT ROUND( -1.5 ); /* = -2 */
SELECT ROUND( 1.4212, 1 ); /* = 1.4 */
SELECT ROUND( 1.4512, 1 ); /* = 1.5 */
答案 1 :(得分:1)
嘿,你可以试试这个 -
select exp(sum(log(coalesce(salary,1)))) as d from employee
您可以获得有关
的更多信息