Name
CEIL
The CEIL function returns the smallest integer greater than an input value that you specify.
ANSI SQL Standard Syntax
ANSI SQL supports the following two forms of the function:
CEIL(expression
) CEILING(expression
)
MySQL and PostgreSQL
MySQL and PostgreSQL support both CEIL and CEILING.
Oracle
Oracle supports only CEIL.
SQL Server
SQL Server supports only CEILING.
Examples
When you pass a positive, non-integer number, the effect of CEIL is to round up to the next highest integer:
SELECT CEIL(100.1) FROM dual;
CEIL(100.1)
------------
101
Remember, though, that with negative numbers, rounding “up” results in a lower absolute value:
SELECT CEIL(−100.1) FROM dual;
CEIL(−100.1)
-------------
−100
Use FLOOR to get behavior opposite to that of CEIL.
Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.