I have searched for this and lot of resources available in the net. But i am struck with this simple question
Rounding int
number to nearest high whole number
ex: 63 to 70
71 to 80
select ROUND(63,1)
select ROUND(63,-1)
Appreciate your help
5条答案
按热度按时间qvtsj1bj1#
Result
mjqavswn2#
You can't use ROUND directly for that, as there's no inbuilt mechanism to do so.
But you can easily just do it another way:
This way you:
Subtract one divide by 10, discarding any rest beyond full 10s, meaning You'll turn 63 into 6 or 70 into 6 (this is important because you don't want to round 70 to 80, I presume. If you do, just don't subtract 1 before dividing). Then add one (this is the rounding up part) and multiply back up by 10.
If you need to use this a lot you can define a custom function to do it for you.
0s7z1bwu3#
Another way:
piah890a4#
Best way is to use ceil, you can do:
For example, 50 would stay 50. 51 through 60 would be 60. 61 would be 70 and so on.
huwehgph5#
Returns