Table 5. ROUND function
Function | Type | Example | Result |
---|---|---|---|
ROUND(number[, length]) |
Number |
ROUND(13.37, 1) |
13.4 |
Example:
USE world;
SELECT name, LifeExpectancy, ROUND(LifeExpectancy)
FROM world.country;
Results:
Table 6. FLOOR, CEILING, TRUNCATE functions
Function | Type | Example | Result |
---|---|---|---|
FLOOR(number) |
number |
FLOOR(7.7) |
7 |
CEILING(number) |
number |
CEILING(6.2) |
7 |
TRUNCATE(NUMBER, length) |
number |
TRUNCATE(7.9) |
7 |
Example:
USE bike;
SELECT list_price, FLOOR(list_price), CEILING(list_price),
TRUNCATE(list_price, 0)
FROM product;
Results:
This content is provided to you freely by EdTech Books.
Access it online or download it at https://edtechbooks.org/learning_mysql/numeric_functions.