---
title: "DB2: CEILING Scalar Function Example"
description: "SQL CEIL function explained with best examples"
url: https://srinimf.com/2015/10/14/ceiling-scalar-function-in-db2-the-result-can-be-null/
date: 2015-10-14
modified: 2020-04-28
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/10/ceil-function-sql.jpg?fit=1200%2C700&ssl=1
categories: ["SQL"]
tags: ["SQL CEIL Example Function", "SQL Scalar functions"]
type: post
lang: en
---

# DB2: CEILING Scalar Function Example

The ‘CEILING’ is basically a built-in function and it is a part of a [scalar function](https://srinimf.com/2015/10/14/aggregate-functions-vs-scalar-functions-in-db2/). The syntax and usage of this function explained here.

*Get ready…. *

## CEILING FUNCTION

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

Syntax is

```
CEILING(numeric-expression)
```

The schema is SYSIBM.

### 3 Rules to Remember

1. The argument must be an expression that returns a value of any built-in numeric data type.
2. The argument can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34).
3. 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 DECIMAL. For example, an argument with a data type of DECIMAL(5,5) results in DECIMAL(5,0).

**The result can be null:**

Let us see how it is…

> if the argument is null, the result will be null.

## Tip: CEIL can be specified as a synonym for CEILING.

**Example 1:**

The following statement shows the use of CEILING on positive and negative values:

```
SELECT CEILING(3.5), CEILING(3.1), CEILING(-3.1), CEILING(-3.5)
FROM SYSIBM.SYSDUMMY1;
```

This example returns: 04., 04., -03, -03.

**Example 2:**

Using sample table DSN8A10.EMP, 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 CEILING(MAX(SALARY)/12)
 FROM DSN8A10.EMP;
```

This example returns 04396. because the highest-paid employee is Christine Haas who earns $52750.00 per year. Her average monthly salary before applying the CEILING function is 4395.83.

*(Ref:IBM)*

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F10%2F14%2Fceiling-scalar-function-in-db2-the-result-can-be-null%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F10%2Fceil-function-sql.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=DB2%3A%20CEILING%20Scalar%20Function%20Example)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/10/14/ceiling-scalar-function-in-db2-the-result-can-be-null/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/10/14/ceiling-scalar-function-in-db2-the-result-can-be-null/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/10/14/ceiling-scalar-function-in-db2-the-result-can-be-null/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/10/14/ceiling-scalar-function-in-db2-the-result-can-be-null/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%3A%20CEILING%20Scalar%20Function%20Example&body=https%3A%2F%2Fsrinimf.com%2F2015%2F10%2F14%2Fceiling-scalar-function-in-db2-the-result-can-be-null%2F&share=email)
-

### Like this:

Like Loading…
