开发者

How To rounded to the lowest multiple of 5 in SQL SERVER 2008?

开发者 https://www.devze.com 2023-04-03 14:31 出处:网络
how to round a number to the开发者_JS百科 minimum number that is a multiple of 5 Examples: if we have 49 it should be rounded to 45 not 50

how to round a number to the开发者_JS百科 minimum number that is a multiple of 5

Examples:

  • if we have 49 it should be rounded to 45 not 50
  • if we have 54 it should be rounded to 50.

This is wrong:

SELECT ROUND(49, -1)


Integer arithmetic will do it

SELECT FLOOR(49/5) * 5,  FLOOR(54/5) * 5
0

精彩评论

暂无评论...
验证码 换一张
取 消