CEILING
CEILING is a mathematical function in SQL that returns the smallest integer that is greater than or equal to a specified numeric expression. It is used to round up a non-integer numeric expression to the nearest whole number.
CEILING(X)
- x: It is the numeric expression which will be rounded up to the smallest integer that is greater than or equal to the input value.
Example
Output
Explanation
The CEILING
function in MySQL rounds up a number to the nearest integer. In this example, the function is applied to the number 7.3. The output is 8 because CEILING
always rounds upwards to the next whole number, so 7.3 is rounded up to 8.
CEILING( numeric_expression )
- numeric_expression: This parameter represents the floating-point number value to be rounded up. CEILING() function in SQL Server takes this value and returns the smallest integer greater than, or equal to, this specified numeric expression.
Example
Output
CeilingValue |
---|
26 |
Explanation
The CEILING
function in SQL Server rounds up the input value to the nearest whole number. Here, the input number is 25.65 which got rounded up to the nearest whole number, 26.
CEILING(numeric_expression) RETURNS numeric
- numeric_expression: This is the only parameter for the CEILING function. It must be an expression that yields a numeric value from which you want to find the smallest integer greater than or equal to the given numeric expression. The value carried by this expression can be a result of some operation or from a column of a table. It can even be a constant. The CEILING function will always round up the number provided as numeric_expression towards positive infinity. If the expression itself returns an integer, CEILING will return the same integer as the output. The numeric_expression parameter does not accept expressions that return non-numeric values.
Example
Output
Explanation
The CEILING function in Oracle is used to return the smallest integer greater than, or equal to, a specified number. In the example above, the function is given the value 7.3. Since 8 is the smallest integer greater than 7.3, the function returns 8.