Name
CEIL
Synopsis
The CEIL function returns the smallest integer greater than an input value that you specify.
SQL2003 Syntax
SQL2003 supports the following two forms of the function:
CEIL(expression
) CEILING (expression
)
DB2
DB2 supports both variations of the SQL2003 syntax.
MySQL
MySQL supports only CEILING.
Oracle
Oracle supports only CEIL.
PostgreSQL
PostgreSQL has no support for either CEIL or CEILING.
SQL Server
SQL Server supports only CEILING.
Examples
When you pass a positive, noninteger number, the effect of CEIL is to round up to the next highest integer:
SELECT CEIL(100.1) FROM dual;
FLOOR(100.1)
------------
101
Remember, though, that with negative numbers, rounding “up” results in a lower absolute value:
SELECT CEIL(-100.1) FROM dual;
FLOOR(-100.1)
-------------
-100
Use FLOOR to get behavior opposite to that of CEIL.
Get SQL in a Nutshell, 2nd 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.