CEIL()
Rounds a number up to the nearest integer (ceiling).
Description
CEIL (also spelled CEILING) rounds a number up to the smallest integer
greater than or equal to it. Use it when you need to "round up", for example,
calculating how many boxes you need if each holds 10 items.
Syntax
CEIL(expression)
CEILING(expression)Parameters
| Name | Description | Optional |
|---|---|---|
| expression | A numeric column or expression. | No |
Return Type
Returns an integer type. The fractional part is discarded by rounding upward.
Examples
Loading playground environment...
Loading playground environment...
CEIL vs FLOOR
CEIL always goes up (toward positive infinity); FLOOR always goes down.
CEIL(-2.7) is -2, while FLOOR(-2.7) is -3.
Common Mistakes
- Confusing with rounding.
CEILdoesn't round to the nearest integer; it always moves up. UseROUNDfor nearest. - Negative numbers.
CEIL(-2.7)is-2, not-3: it moves toward positive infinity. - Expecting decimals. The result is an integer.
Related Functions
See also: FLOOR, ROUND.
Cite this resource
SQLSimplified. "CEIL() SQL Function". Available at: https://sqlsimplified.online/reference/ceil