CEILING

The CEIL or CEILING function returns the smallest integer value that is greater than or equal to expression.

CEILINGCEIL(expression)
expression
An expression that returns a value of any built-in numeric, character-string, or graphic-string data type. A string argument is cast to double-precision floating point before evaluating the function. For more information about converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE.

The result of the function has the same data type and length attribute as the argument except that the scale is 0 if the argument is a decimal number. For example, an argument with a data type of DECIMAL(5,5) will result in DECIMAL(5,0).

If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Note

Results involving DECFLOAT special values: For decimal floating-point values, the special values are treated as follows:
  • CEILING(NaN) returns NaN.
  • CEILING(-NaN) returns -NaN.
  • CEILING(Infinity) returns Infinity.
  • CEILING(-Infinity) returns -Infinity.
  • CEILING(sNaN) and CEILING(-sNaN) return a warning or error.1

Examples

  • Find the highest monthly salary for all the employees. Round the result up to the next integer. The SALARY column has a decimal data type
      SELECT CEIL(MAX(SALARY)/12)
        FROM EMPLOYEE
    This example returns 4396.00 because the highest paid employee is Christine Haas who earns $52750.00 per year. Her average monthly salary before applying the CEIL function is 4395.83.
  • Use CEILING on both positive and negative numbers.
      SELECT CEILING( 3.5),
             CEILING( 3.1),
             CEILING(-3.1),
             CEILING(-3.5)
        FROM SYSIBM.SYSDUMMY1
    This example returns:
    04.   04.  -03.  -03.
1 If *YES is specified for the SQL_DECFLOAT_WARNINGS query option, NaN and -NaN are returned respectively with a warning.