MySQL CEIL() function
CEIL() function
MySQL CEIL() returns the smallest integer value not less than the number specified as an argument. The synonym of CEIL() is CEILING().
This function is useful in -
- CEIL() is essential when you need to obtain the smallest integer that is greater than or equal to a given number.
- CEIL() ensures that you get the next highest integer.
- CEIL() is crucial when dealing with boundary conditions or limits where you need to ensure that a value falls on or above a certain threshold.
- In finance and accounting, CEIL() is used when dealing with monetary values, ensuring that rounding up is applied consistently.
- In inventory management systems, CEIL() can be used to round up quantities to ensure that enough stock is available for orders.
- In certain statistical calculations and simulations, CEIL() may be used to ensure that whole numbers are used in the analysis.
Syntax:
CEIL(N);
Argument:
Name | Description |
---|---|
N | A number. |
Syntax Diagram:
MySQL Version: 8.0
Pictorial presentation of CEIL() Function
Example:
The following MySQL statement returns 3 which is the smallest integer value not less than the value specified (2.2536) in the argument.
Code:
SELECT CEIL(2.2536);
Output:
mysql> SELECT CEIL(2.2536); +--------------+ | CEIL(2.2536) | +--------------+ | 3 | +--------------+ 1 row in set (0.01 sec)
Example : CEIL() function with negative value
The following MySQL statement returns -2 which is the smallest integer value not less than the value specified (-2.2536) in the argument.
Code:
SELECT CEIL(-2.2536);
Output:
mysql> SELECT CEIL(-2.2536); +---------------+ | CEIL(-2.2536) | +---------------+ | -2 | +---------------+ 1 row in set (0.00 sec)
Comparing between CEIL() function and FLOOR() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/mysql/mathematical-functions/mysql-ceil-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics