我使用MySQL并希望显示SELECT查询中的值(它们都是小数),如下所示:当数字有非零小数时,它应该四舍五入为小数位;当它是整数时,则显示为没有小数位。
因此,3.26应该显示为3.3,而5.00应该显示为5。
当我对上面的内容使用ROUND(x,1)时,分别得到了3.3和5.0。
发布于 2015-06-21 19:11:51
试着像这样
select
case (yournumber mod 1 > 0)
when true then round(yournumber, 1)
else round(yournumber,0)
end
from tablename;https://stackoverflow.com/questions/30968276
复制相似问题