在SQL Server中将* UP *舍入到最接近的100 [英] Round *UP* to the nearest 100 in SQL Server
本文介绍了在SQL Server中将* UP *舍入到最接近的100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在SQL Server中是否可以轻松地将数字向上舍入到最接近的100(或1000、500、200等)?
Is it possible to easily round a figure up to the nearest 100 (or 1000, 500, 200 etc.) in SQL Server?
所以:
720-> 800
790-> 800
1401-> 1500
720 -> 800
790 -> 800
1401 -> 1500
推荐答案
以下内容应该可以工作.阅读完您的问题后,我不确定您要100退还多少.对于这100个返回100.
The following should work. After reading your question, I'm not exactly sure what you want 100 to return. For this 100 returns 100.
select floor((X + 99) / 100) * 100;
这将产生以下结果:
0 -> 0
1 -> 100
99 -> 100
100 -> 100
101 -> 200
这篇关于在SQL Server中将* UP *舍入到最接近的100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文