access_time 2 years ago languageEnglish
more_vert

Teradata SQL - COALESCE and NULLIF Functions

visibility 464 comment 0

COALESCE function in Teradata returns NULL if all arguments evaluate to null; otherwise it returns the value of the first non-null argument. NULLIF is 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

copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn.

Want to contribute on Kontext to help others?

Learn more

More from Kontext

visibility 37
thumb_up 0
access_time 4 months ago
visibility 316
thumb_up 0
access_time 4 months ago
visibility 494
thumb_up 0
access_time 7 months ago