Function Reference

CEILING

A synonym for CEIL: returns a number rounded up to the nearest integer.

PostgreSQL 17.9
CEILING(num)
num
Number to round
numeric | double precision

Return value

A whole value: numeric for numeric, double precision for double precision and for an integer argument

Examples

Positive and negative number

PostgreSQL 17.9
SELECT CEILING(4.1) AS up,
	CEILING(-4.1) AS negative;
upnegative
5-4

How many boxes of 3 are needed

PostgreSQL 17.9
SELECT good,
	SUM(amount) AS units,
	CEILING(SUM(amount) / 3.0) AS boxes_of_three
FROM Payments
GROUP BY good
ORDER BY good;
goodunitsboxes_of_three
121
452
542
6104
721
811
93211
1011
1111
1311

Details

CEILING and CEIL work the same. Negative numbers are rounded towards zero: CEILING(-4.1) returns -4.

See also

Where to learn