[英]MySQL remove zeros from decimal part if the number is whole
I have a sales table with price
column as decimal(8, 2)
and I'm running the query below to get the total price我有一个销售表,
price
列为decimal(8, 2)
,我正在运行下面的查询以获取总价
select sum(case when status = 1 then price * quantity when status = 2 then price * quantity * -1 else 0 end) as total from sales;
It's working perfectly but my results are usually intergers so I end up with trailing zeros all the time.它工作得很好,但我的结果通常是整数,所以我总是以尾随零结束。 It'd be nice to just return the whole number if there is no decimal part
如果没有小数部分,最好只返回整数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.