Round to .5 or 1.0 in SQL

前端 未结 2 741
半阙折子戏
半阙折子戏 2020-12-11 00:49

I\'m looking to round values like

2.3913 -> 2.5

4.6667 -> 4.5

2.11 -> 2

How can I manage this in SQL?

相关标签:
2条回答
  • 2020-12-11 00:58
    SELECT ROUND(2.2 * 2, 0) / 2 
    

    gets you to the nearest .5

    0 讨论(0)
  • 2020-12-11 01:16

    round(round(column/5,1)*5,1) closest 0.5
    round(round(column/5,2)*5,2) closest 0.05

    0 讨论(0)
提交回复
热议问题