Round *UP* to the nearest 100 in SQL Server

后端 未结 13 788
野性不改
野性不改 2020-12-25 11:18

Is it possible to easily round a figure up to the nearest 100 (or 1000, 500, 200 etc.) in SQL Server?

So:

720 -> 800
790 -> 800
1401 -> 1500

13条回答
  •  礼貌的吻别
    2020-12-25 11:25

    One option would be to use the CEILING() function like this:

    SELECT CEILING(@value/100.0) * 100
    

    You may need to convert your value to a decimal first depending on its type.

提交回复
热议问题