SQL FLOOR AND CEILING FUNCTIONS

sql-floor-ceiling
Spread the love

FLOOR() Function:

SQL FLOOR is used to return the largest integer less than or equal to the specified numeric expression.

Syntax:

FLOOR(NUMERIC VALUE)

EXAMPLE:

 SELECT FLOOR(26.66);
SELECT FLOOR(-2.55);
SELECT FLOOR($35.42);

The result is the numeric part with the same data type.

CEILING() Function:

SQL CIELING() is used to get the smallest integer greater than, or equal to, the specified numeric expression as return value.

Synatx:

CIELING(NUMERIC VALUE)

EXAMPLE:

SELECT CEILING(26.66);
SELECT CEILING(-2.55);
SELECT CEILING($35.42);

The result is the numeric part with the same data type.

Compare the FLOOR() and CEILING() results with each other to learn what is happening with each type of numeric values

Thanks For Reading!

SOURCE: Microsoft T-SQL FLOOR(), CEILING()

READ MORE : LEARN SQL FAST