Oracle CEIL() Function

Oracle CEIL() is a built-in function that returns the smallest integer value greater than or equal to a specified number.

Oracle CEIL() syntax

Here is the syntax for the Oracle CEIL() function:

CEIL(num)

Parameters

num

Required. It can be any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type.

Return Value

The Oracle CEIL() function returns the smallest integer value greater than or equal to the specified number. The function returns the same data type as the parameter’s numeric data type.

If any parameter is NULL, CEIL() will return NULL.

Oracle CEIL() Examples

Here are some examples that demonstrate the usage of the Oracle CEIL() function.

Basic Usage

SELECT
    CEIL(7.2),
    CEIL(-7.2)
FROM dual;

Output:

   CEIL(7.2)    CEIL(-7.2)
____________ _____________
           8            -7

CEIL() vs FLOOR()

The following statement demonstrates the difference between CEIL() and FLOOR():

SELECT
    CEIL(7.2),
    FLOOR(7.2),
    CEIL(-7.2),
    FLOOR(-7.2)
FROM dual;

Output:

   CEIL(7.2)    FLOOR(7.2)    CEIL(-7.2)    FLOOR(-7.2)
____________ _____________ _____________ ______________
           8             7            -7             -8

CEIL() vs ROUND()

The following statement CEIL() demonstrates ROUND() the difference between and :

SELECT
    CEIL(7.2),
    ROUND(7.2),
    CEIL(7.6),
    ROUND(7.6)
FROM dual;

Output:

   CEIL(7.2)    ROUND(7.2)    CEIL(7.6)    ROUND(7.6)
____________ _____________ ____________ _____________
           8             7            8             8

NULL Parameters

If any parameter is NULL, CEIL() will return NULL.

SET NULL 'NULL';
SELECT
    CEIL(NULL)
FROM dual;

Output:

   CEIL(NULL)
_____________
         NULL

In this example, we use the statement SET NULL 'NULL'; to display NULL values as the string 'NULL'.

Conclusion

Oracle CEIL() is a built-in function that returns the smallest integer value greater than or equal to a specified number.