MySQL 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.
MySQL Version: 8.0
Pictorial presentation of CEIL() Function
The following MySQL statement returns 3 which is the smallest integer value not less than the value specified (2.2536) in the argument.
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.
mysql> SELECT CEIL(-2.2536); +---------------+ | CEIL(-2.2536) | +---------------+ | -2 | +---------------+ 1 row in set (0.00 sec)
Comparing between CEIL() function and FLOOR() function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join