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 2:
select nvl(cast(null as char(1)), 'a') from (values(1)) x(a);
(EXPR)
------
a
--- 1 row(s) selected.
This function returns a value of 1:
select nvl(1, 2) from (values(1)) x(a)
(EXPR)
-------
1
--- 1 row(s) selected.
This function is for the math function COS.
select nvl (cos(1),(2) from (values(1)) x(a);
(EXPR)
----------------------
5.40302305868139648E-001
--- 1 row(s) selected.
This function is for the column name.
select nvl (cast(null as int), a) from t;
(EXPR)
-------------
--- 2 row(s) selected.
select * from t;
A
-------------
--- 2 row(s) selected.
123
34
123
34
NVL Function
379

Advertisement

Table of Contents
loading

Table of Contents