Nvl Function; Examples Of Nvl - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

NVL Function

The NVL function determines if the selected column has a null value and then returns the
new-operand value; otherwise the operand value is returned.
NVL (operand, new-operand)
operand
specifies a value expression.
new-operand
specifies a value expression. operand and new-operand must be comparable data types.
If operand is a null value, NVL returns new-operand.
If operand is not a null value, NVL returns operand.
The operand and new-operand can be a column name, subquery, Neoview SQL string functions,
math functions, or constant values.

Examples of NVL

This function returns a value of z:
select nvl(cast(null as char(1)), 'z') from (values(1)) x(a);
(EXPR)
------
"z"
--- 1 row(s) selected.
This function returns a value of 1:
select nvl(1, 2) from (values(0)) x(a)
(EXPR)
-------
1
--- 1 row(s) selected.
This function returns a value of 9999999 for the null value in the column named a1:
select nvl(a1, 9999999) from t1;
(EXPR)
-------
123
34
9999999
--- 3 row(s) selected.
select * from t1;
A1
-------
123
34
?
--- 3 row(s) selected.
436
SQL Functions and Expressions

Advertisement

Table of Contents
loading

Table of Contents