PostgreSQL 18 reference · Math Functions

PostgreSQL CEIL() Function

Round a number up to the nearest integer: ceil(2.1) is 3 and ceil(-2.1) is -2. ceiling() is a synonym.

PostgreSQL 18

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

ceil(x)  |  ceiling(x)

Parameters

ParameterDescription
x A number (integer, numeric or double precision).

Return value

A number of the input type.

Examples

Round up
SELECT ceil(2.1) AS a, ceil(-2.1) AS b;

Output

 a | b
---+----
 3 | -2
(1 row)

Run this on your computer — see “Get Started” for setup.

Pages needed
SELECT count(*) AS products, ceil(count(*) / 5.0) AS pages_of_5
FROM products;

Output

 products | pages_of_5
----------+------------
       12 |          3
(1 row)

Run this on your computer — see “Get Started” for setup.

In other languages

Was this page helpful?