This tutorial explains how to use the MySQL ROUND function with syntax and examples.
The MySQL ROUND function returns a number rounded to a certain number of decimal places.
The syntax for the ROUND function in MySQL is:
ROUND( number, [ decimal_places ] )
The number to round.
The number of decimal places to round. This value must be a positive or negative integer. If this parameter is omitted, the ROUND function will round the number to 0 decimal places.
The ROUND function can be used in the following versions of MySQL:
Let's look at some MySQL ROUND function examples and explore how to use the ROUND function in MySQL.
For example:
mysql> SELECT ROUND(125.315);
Output: 125
mysql> SELECT ROUND(125.315, 0);
Output: 125
mysql> SELECT ROUND(125.315, 1);
Output: 125.3
mysql> SELECT ROUND(125.315, 2);
Output: 125.32
mysql> SELECT ROUND(125.315, -1);
Output: 130
mysql> SELECT ROUND(125.315, -2);
Output: 100
mysql> SELECT ROUND(-125.315);
Output: -125