ceil(numeric) — Round up to the nearest integer
Last updated: 2026-11-04
ceil(numeric) — Round up to the nearest integer
ceil() rounds a value up to the nearest integer; ceiling() is an alias and floor() rounds down. They come in handy for inventory day counts, page counts and "at least how many are needed" calculations. The result type follows the input, so numeric input yields a numeric result.
| Kind | function |
|---|---|
| Example Language | SQL |
📝 Syntax
ceil(value numeric) → numeric
ceiling(value numeric) → numeric
floor(value numeric) → numeric
⚙️ Parameters
| value numeric | The value to round. Type numeric; double precision and other numeric types are also accepted. |
|---|
Returns:numeric — the value rounded up.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
id | label | qty | ceil_qty | floor_qty
----+----------+-------+----------+-----------
1 | boxes | 12.10 | 13 | 12
2 | exact | 12.00 | 12 | 12
3 | negative | -3.20 | -3 | -4
(3 rows)
📌 Key Points
- ceil(-3.20) gives -3 and floor(-3.20) gives -4, so the direction is well defined for negatives too.
- A value that is already an integer is returned unchanged.
- For pagination, ceil(total / page_size) gives the number of pages needed.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QWhat is the difference between ceil() and ceiling()?
AThere is none — ceiling() is simply an alias for ceil() and behaves identically.