PostgreSQL ceil() Function

The PostgreSQL ceil() function returns the smallest integer value that is greater than or equal to the number specified by the argument.

The PostgreSQL ceil() function and ceiling() function are exactly the same.

ceil() Syntax

This is the syntax of the PostgreSQL ceil() function:

ceil(numeric_value) -> integer

Parameters

numeric_value

Required. A number, it can be positive, negative, or zero, it can be an integer or a decimal.

Return value

The PostgreSQL ceil() function returns the smallest integer value that is greater than or equal to the number specified by the argument.

The ceil() function will return NULL if the argument is NULL.

PostgreSQL will give an error if you supply a parameter that is not a numeric type.

ceil() Examples

Here are a few examples of the ceil() function:

SELECT
    ceil(0) AS "ceil(0)",
    ceil(10) AS "ceil(10)",
    ceil(10.11) AS "ceil(10.11)",
    ceil(-10.11) AS "ceil(-10.11)";
 ceil(0) | ceil(10) | ceil(10.11) | ceil(-10.11)
---------+----------+-------------+--------------
       0 |       10 |          11 |          -10