CEILING

In SQL, the CEILING function is used to round a numeric value up to the nearest integer or specified decimal places. The CEILING function returns the smallest integer that is greater than or equal to the specified numeric expression.

Syntax

The syntax for the CEILING function in SQL is as follows:

CEILING(numeric_expression)

Where numeric_expression is the value that you want to round up to the nearest integer.

Example

Here’s an example to illustrate the use of the CEILING function:

SELECT CEILING(3.14);

This query would return the value 4, as 4 is the smallest integer that is greater than or equal to 3.14.

You can also specify the number of decimal places to round up to using the CEILING function. For example, to round up to the nearest tenth, you would use the following query:

SELECT CEILING(3.14 * 10) / 10;

This query would return the value 3.2, as 3.2 is the smallest number that is greater than or equal to 3.14 rounded up to the nearest tenth.

In conclusion, the CEILING function in SQL is a useful tool for rounding up numeric values to the nearest integer or specified decimal places. It can be used to simplify calculations and formatting of data in a SQL query.