Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (5k points)

Is there any function or any other way to round a number to the lowest whole value? Something like floor, but to a specified increment like 10. 


0.766,5.0883, 9, 9.9999 would all be floored to 0 11.84848, 15.84763, 19.999 would all be floored to 10 etc...

I want to fit numbers in the ranges of 0, 10, 20, 30, etc

Is there any way to achieve it with different ranges? For example 0, 100, 200, 300, etc

1 Answer

0 votes
by (10.2k points)

This can be done by using arithmetic and floor():

select 10*floor(val / 10)

You can replace the 10s with whatever value you want.

If you want to get more insights into SQL, check out this SQL Course from Intellipaat.

Browse Categories