mysql查询以圆形为基础的特定小数值(mysql query to round based specific decimal values)

编程入门 行业动态 更新时间:2024-10-14 04:25:18
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.99

and I want query the result like this :

1122.46 4600 2000.56 5250

where 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.01

Testing 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

更多推荐

本文发布于:2023-08-05 21:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数值   圆形   基础   mysql   query

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!