2017-01-17 49 views
-2

我有一个数字在MySQL这样和数字逗号后

549.97 
550.565 
395.815 
315.9 
and so on 

,当我运行查询和

select 549.97 + 550.565 + 395.815 + 315.9 

我得到这个结果

1812.250 

这是不正确的

那是因为逗号后的数字有时是一个,有时两有时三..

怎么可能我让数字是正确的额头时,我有一个或两个或三个数字在MySQL

逗号后

这是我的表查询

select sum(voucher_amount) from vouchers where voucher_amount > 0 

我总是错号码 甚至当我尝试圆得像

select round(sum(voucher_amount),2) from vouchers where voucher_amount > 0 

因为逗号

+1

你能分享样品数据和所需结果吗 –

+0

你想要什么样的产品? –

+1

'549.97 + 550.565 + 395.815 + 315.9是1812.25'这相当于'1812.250',所以你怎么能说这是不正确的? – KuKeC

回答

1

根据TRUNCATE Function后有只有一个数字号码,试试这个:

select TRUNCATE(sum(voucher_amount) , 2) from vouchers where voucher_amount > 0 

这似乎是正确的。