mysql查询以圆形为基础的特定小数值(mysql query to round based specific decimal values)
我可以对基于值的特定十进制值进行舍入,我的mysql表中有这些数据:
1122.46 4599.99 2000.56 5249.99我想查询结果如下:
1122.46 4600 2000.56 5250其中只有小数点数为.99的值被四舍五入。
Can I round up value based specific decimal values,I have this data in my mysql table :
1122.46 4599.99 2000.56 5249.99and I want query the result like this :
1122.46 4600 2000.56 5250where only values which have .99 decimal point is rounded up.
最满意答案
我能想到的唯一方法是:
SELECT `number` + (FLOOR(`number` + 0.01)-FLOOR(`number`))*0.01测试它:
5249.99 + (FLOOR(5249.99 + 0.01)-FLOOR(5249.99))*0.01 = 5250
1122.46 + (FLOOR(1122.46 + 0.01)-FLOOR(1122.46))*0.01 = 1122.46
The only way I could think of is:
SELECT `number` + (FLOOR(`number` + 0.01)-FLOOR(`number`))*0.01Testing it:
5249.99 + (FLOOR(5249.99 + 0.01)-FLOOR(5249.99))*0.01 = 5250
1122.46 + (FLOOR(1122.46 + 0.01)-FLOOR(1122.46))*0.01 = 1122.46
更多推荐
发布评论