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


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:

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.