ROUND
Returns a number rounded to the specified number of decimal places.
MySQL 8.1
ROUND(num[, decimals])- [ ]optional part
- num
- Number to roundDECIMAL
- decimals
- Number of decimal places, 0 by default, can be negativeINTOptional
Return value
A number of the same type as num
Examples
To a whole number
MySQL 8.1
SELECT ROUND(27.89);To tenths
MySQL 8.1
SELECT ROUND(27.89, 1);To tens
MySQL 8.1
SELECT ROUND(27.89, -1);Average price to hundredths
MySQL 8.1
SELECT ROUND(AVG(unit_price), 2) AS avg_price
FROM Payments;Details
Exact numbers (integers and DECIMAL) round halves away from zero: ROUND(2.5) returns 3, and ROUND(-2.5) returns -3.
With a negative decimals, digits to the left of the decimal point are rounded: ROUND(1234, -2) returns 1200. Approximate numbers (DOUBLE, for example 2.5E0 or the result of SQRT) are rounded to the nearest even number: ROUND(2.5E0) returns 2. A decimals value greater than 30 in absolute value is treated as 30.