Postgresql Ceil Function

PostgreSQL: ceil Function

In this PostgreSQL post explains how to use the PostgreSQL ceil function with syntax and examples.

Description

The PostgreSQL ceil function returns the smallest integer value that is greater than or equal to a number.

Syntax

The syntax for the ceil function in PostgreSQL is:

ceil( number )

Parameters or Arguments

number

The value used to find the smallest integer value.

Note

Applies To

The ceil function can be used in the following versions of PostgreSQL:

  • PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4

Example

Let's look at some PostgreSQL ceil function examples and explore how to use the ceil function in PostgreSQL.

For example:

postgres=# SELECT ceil(32.65);
 ceil
------

   33
(1 row)

postgres=# SELECT ceil(32.1);
 ceil
------

   33
(1 row)

postgres=# SELECT ceil(32);
 ceil
------

   32
(1 row)

postgres=# SELECT ceil(-32.65);
 ceil
------

  -32
(1 row)

postgres=# SELECT ceil(-32.1);
 ceil
------

  -32
(1 row)

postgres=# SELECT ceil(-32);
 ceil
------

  -32
(1 row)