3.2

# Numeric Functions

### ROUND

• The ROUND function has two parameters. The first is a number, usually a DECIMAL or a FLOAT. The second defines the number of decimals to which the number will be rounded.
• If no length is provided, the number is rounded to a whole number.

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:

### FLOOR, CEILING, TRUNCATE

• FLOOR() will return the next lowest whole number no matter what the decimal point.
• CEILING() will return the next highest whole number no matter what the decimal point.
• TRUNCATE() will return the number truncated to the precision specified.

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:

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.

### End-of-Chapter Survey

: How would you rate the overall quality of this chapter?
1. Very Low Quality
2. Low Quality
3. Moderate Quality
4. High Quality
5. Very High Quality
Comments will be automatically submitted when you navigate away from the page.