CEIL

CEIL is a mathematical function in SQL that rounds up a numeric value to its nearest integer.

CEIL(X)

  • x: This is the value to be rounded. It could be a numeric type such as INT, DECIMAL, FLOAT, or DOUBLE whose ceiling value is to be calculated. CEIL(X) function rounds the value of X up to the nearest integer that is greater than or equal to X.

Example

SELECT CEIL(15.75);

Output

16

Explanation

The CEIL() function in MySQL is used to round a number up to its nearest whole integer. In the provided example, the number 15.75 was rounded up to 16.

CEIL(number)

  • number: It indicates the numeric value for which you want to find the smallest integer that is greater than or equal to it. The CEIL() function then returns this integer.

Example

SELECT CEIL(17.56), CEIL(-17.56);

Output

18 | -17

Explanation

The CEIL() function in PostgreSQL rounds up a number to the nearest integer. If the number is positive, then it rounds up to the next highest integer. If the number is negative, then it rounds up towards zero, resulting in a lesser absolute value. Therefore, CEIL(17.56) returned 18 and CEIL(-17.56) returned -17.

CEIL(number)

  • number: The numeric expression to round up to the nearest integer. This can be a numeric literal, a numeric column of a table, or the result of another function or operation that yields a numeric value. The CEIL function operates on both positive and negative values and returns the smallest integer value that is greater than or equal to this parameter.

Example

SELECT CEIL(15.56) FROM dual;

Output

16

Explanation

The CEIL function in Oracle SQL is used to round up an input number to the nearest integer. In the given example, CEIL(15.56) returns ‘16’ as ‘16’ is the nearest integer that is greater than ‘15.56’.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.