Function Reference

ROUND

Returns a number rounded to the specified number of decimal places.

MySQL 8.1
ROUND(num[, decimals])
  • [ ]optional part
num
Number to round
DECIMAL
decimals
Number of decimal places, 0 by default, can be negative
INTOptional

Return value

A number of the same type as num

Examples

To a whole number

MySQL 8.1
SELECT ROUND(27.89);
ROUND(27.89)
28

To tenths

MySQL 8.1
SELECT ROUND(27.89, 1);
ROUND(27.89, 1)
27.9

To tens

MySQL 8.1
SELECT ROUND(27.89, -1);
ROUND(27.89, -1)
30

Average price to hundredths

MySQL 8.1
SELECT ROUND(AVG(unit_price), 2) AS avg_price
FROM Payments;
avg_price
3231.18

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.

See also

Where to learn