Search code examples
mysqlrounding

How can I round a number down to the nearest 10?


In MySQL I would like to round numbers down to the nearest ten.

e.g. 812 -> 810, but also 819 -> 810

Using the ROUND function does not do the trick.


Solution

  • You could use TRUNCATE function as follow:

    SELECT TRUNCATE(819, -1);
    SELECT TRUNCATE(812, -1);
    
    Result:
    810