Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

SQL CEIL() function

CEIL() function

SQL CEIL() function is used to get the smallest integer which is greater than, or equal to, the specified numeric expression.

Syntax:

CEIL(expression)

Parameters:

Name Description
expression An expression which is a numeric value or numeric data type.The bit data type is not allowed.

MySQL, PostgreSQL, and Oracle

All of above platforms support the SQL syntax of CEIL().

SQL CEIL() function: Pictorial presentation

SQL CEIL FUNCTION

SQL CEIL() function on positive value

To get the ceiling or nearest rounded up value of 17.36 from the DUAL table , the following SQL statement can be used :

SELECT(CEIL(17.36)) 
FROM dual; 

Output:

(CEIL(17.36))
-------------
           18

Example:

To get the ceiling or nearest rounded up value of -17.36 from the DUAL table, the following SQL statement can be used :

SELECT CEIL(-17.36) 
FROM dual;

Output:

CEIL(-17.36)
------------
         -17

SQL CEIL() function with distinct

Sample table : agents


To get the unique ceiling or nearest rounded up value of the column 'commission' after multiplying by 75 from the 'agents' table, the following SQL statement can be used :

SELECT DISTINCT(CEIL(commission*75)) "DISTINCT(CEIL())" 
FROM agents;

Output:

DISTINCT(CEIL())
----------------
              11
              10
               9
              12

SQL: Comparing between CEIL() and FLOOR() function

SQL: Comparing between ceil and floor function

Note: Outputs of the said SQL statement shown here is taken by using Oracle Database 10g Express Edition.

Here is a slide presentation which covers the SQL arithmetic functions.

Practice SQL Exercises

Want to improve the above article? Contribute your Notes/Comments/Examples through Disqus.

Previous: ABS
Next: FLOOR



SQL: Tips of the Day

SQL Server SELECT into existing table.

INSERT INTO dbo.TABLETWO
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

This assumes there's only two columns in dbo.TABLETWO - you need to specify the columns otherwise:

INSERT INTO dbo.TABLETWO
  (col1, col2)
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

Database: SQL Server

Ref: https://bit.ly/3y6tpA3