CEILING
A synonym for CEIL: returns a number rounded up to the nearest integer.
PostgreSQL 17.5
CEILING(num)Parameters
- numnumeric | double precision
- Number to round
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.5
SELECT CEILING(4.1) AS up,
CEILING(-4.1) AS negative;How many boxes of 3 are needed
PostgreSQL 17.5
SELECT good,
SUM(amount) AS units,
CEILING(SUM(amount) / 3.0) AS boxes_of_three
FROM Payments
GROUP BY good
ORDER BY good;Details
CEILING and CEIL work the same. Negative numbers are rounded towards zero: CEILING(-4.1) returns -4.