All You Need NULL Value Functions

The below are the Null value functions in Tearadata. One is "NVL" and another one is "NVL2". These two functions are part of Teradata SQL.

NVL -The NVL function replace null value with a string or numeric value. This is the functionality is same as Teradata function NULLIF. It requires two arguments. If the value is not null, it will not do anything.


The best SQL Null functions 

NVL function: 

SELECT NVL (NULL,'USA'), NVL('SPAIN','USA');
-----------
USA SPAIN

Also Read: Top 70 Teradata Interview Questions

The NVL2 function :

Returns one of two specified values (arguments#2 and Arguments#3) based on weather the first arguments in NULL or not. It requires three arguments.

The rule is as follows:
  1. If expression 1 is not null, expression 2 is returned
  2. If expression 1 is null, expression 3 is returned

The best NVL2 example

SELECT NVL2(NULL,'FRANCE','SPAIN'), NVL2('ENGLAND','FRANCE','SPAIN')
-------------------
SPAIN FRANCE

Comments

Popular posts from this blog

SQL for Quantile Function in Teradata

3 Uses of SAMPLE function in Teradata

3 Types of Temporal Tables in Teradata