Oracle SQL_Null Related functions-3_NULLIF


admin Functions, Oracle ,

Hi Aliens,
Today, we will talk about another Null Related Function, NULLIF.
You can read my notes on NVL, NVL2 and COALESCE. Please have a look if you haven’t yet.


NULLIF(expr1, expr2)

As you can see in the above syntax that NULLIF accepts only 2 parameters. If expr1 and expr2 are same then function returns NULL else expr1.
Parameters can be column name as well as any literal value. Also, expr1 can never be literal NULL and both parameters should be in same datatype.

Let’s do some examples as they always play a major part in understanding the concept.


You can see in the above code. expr1 and expr2 are same so function returned NULL.


This time expr1 and expr2 are not same so function returned expr1.
What if we put expr1 in number datatype and expr2 in char datatype.


So in this case, it returns an error. So expr1 and expr2 should always be in same datatype.

That’s it for NULLIF. If you have any questions/suggestions, please comment below or write me an email.

If you like this blog, do share with your friends and colleagues on your social media.
For more updates join my facebook group and do like my facebook page.

Thank you,
Kapil Kumar

Sharing is caring!

You May Also Like..


Parentheses in SQL

Hey time travellers, Though Parentheses are used pretty much everywhere in SQL but in this blog, we will talk about […]

Logical Conditions

Oracle – Logical Conditions

Hey time travellers, In this article, we will be discussing Logical Conditions. It is a very important aspect of SQL. […]


Oracle – IN Condition

Hey people, In this Oracle tutorial, we will learn how to use IN condition in SQL. IN condition is used […]

Leave a Reply

Your email address will not be published. Required fields are marked *