ROUND()
- Rounds a NumberRounds a number to the nearest integer or to a specified number of decimal places.
ROUND(number, decimal_places)
decimal_places
is omitted, it rounds to the nearest integer.decimal_places
is positive, it rounds to that many decimal places.decimal_places
is negative, it rounds to the nearest 10, 100, etc.SELECT ROUND(12.567, 2); -- Rounds to 2 decimal places
SELECT ROUND(12.567); -- Rounds to nearest integer
SELECT ROUND(125.67, -1); -- Rounds to nearest 10
Output:
12.57
13
130
TRUNCATE()
- Truncates a NumberCuts off a number to a specified number of decimal places without rounding.
TRUNCATE(number, decimal_places)
SELECT TRUNCATE(12.567, 2); -- Cuts off after 2 decimal places