Teradata SQL - COALESCE and NULLIF Functions

Raymond Tang Raymond Tang 1 5311 2.76 index 3/15/2020

COALESCEfunction in Teradata returns NULL if all arguments evaluate to null; otherwise it returns the value of the first non-null argument. NULLIFis to used evaluate two expressions and returns NULL if the two arguments are equal otherwise if returns the first arguments. IS NULL is used to examine whether one expression is null or not.

COALESCE code snippet

-- returns 1 
select coalesce(1,2,null);

-- returns 2
select coalesce(null,2,null);

NULLIF code snippet

-- returns d as not equal
select  nullif('d','e');

-- returns null as values are equal
select  nullif('2',2);

-- returns null as values are equal
select  nullif('abc','abc');

IS NULL code snippet

-- returns 2
select  
        case 
            when 'e' is null then '1' 
            else '2' 
        end;

Teradata COALESCEĀ Teradata IS NULLĀ Teradata NULLIF

sql teradata

Join the Discussion

View or add your thoughts below

Comments