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: