---
title: "NVL and COALESCE Functions Basic Differences in DB2"
description: "The NVL function returns the first argument that is not null. ==>NVL(expression1, expression2) The arguments are evaluated in the order in which they are specified, and the result of the function is t..."
url: https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/
date: 2015-11-08
modified: 2021-10-16
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/11/pexels-photo-7123050.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2", "DB2 V11"]
tags: ["COALESCE function in DB2", "NVL function in DB2"]
type: post
lang: en
---

# NVL and COALESCE Functions Basic Differences in DB2

The NVL function returns the first argument that is not null.

```
==>NVL(expression1, expression2)
```

The arguments are evaluated in the order in which they are specified, and the result of the function is the first argument that is not null.

The result can be null only if all the arguments can be null, and the result is null only if all the arguments are null. **Also You May Like:** [RTRIM and LTRIM Functions in SQL](https://srinimf.com/2012/07/04/db2-sql-ltrim-rtrim-and-trim/)

---

Advertisements

---

This SQL will return the names of all departments, along with the manager number. If there is no manager for the department, a value of “ABSENT” is displayed.

```
SELECT DEPTNO, DEPTNAME, NVL(MGRNO, 'ABSENT') 
AS MGRNO, ADMRDEPT 
FROM DEPARTMENT;
```

*Read more at:*

- [DB2- Use of ‘COALESCE’ Function (1 of 2)](http://srinimf.com/2012/04/19/db2-use-of-coalesce-function/)
- [DB2- Use of ‘COALESCE’ Function (2 of 2)](http://srinimf.com/2015/06/19/db2-use-of-coalesce-function-2-of-2/)

### 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%2F11%2F08%2Fnvl-and-coalesce-functions-basic-differences-in-db2%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F11%2Fpexels-photo-7123050.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=NVL%20and%20COALESCE%20Functions%20Basic%20Differences%20in%20DB2)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/11/08/nvl-and-coalesce-functions-basic-differences-in-db2/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20NVL%20and%20COALESCE%20Functions%20Basic%20Differences%20in%20DB2&body=https%3A%2F%2Fsrinimf.com%2F2015%2F11%2F08%2Fnvl-and-coalesce-functions-basic-differences-in-db2%2F&share=email)
-

### Like this:

Like Loading…
