3.2

Numeric Functions

ROUND

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:

05_functions.png

FLOOR, CEILING, TRUNCATE

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:

06_functions.png

CC BY-NC-ND International 4.0

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.