DIFFERENCE BETWEEN IFNULL AND NULLIF FUNCTION
These SQL functions are compatible with mysql, SQL Server, Power BI, Big query.
IFNULL FUNCTION: If the in-parameter is NULL then it returns the default out-parameter.
Syntax : IFNULL (<in-parameter>,<out-parameter>)
NULLIF FUNCTION: If the first in-parameter is equal/same to the second in-parameter it returns NULL. If the first in-parameter is not equal/same to the second in-parameter it returns the first in-parameter.
Syntax : NULLIF (<in-parameter-1>,<in-parameter-2>)
IFNULL( ) VS NULLIF( ) FUNCTION:
Features |
IFNULL |
NULLIF |
Syntax |
IFNULL (<in-parameter>, |
NULLIF (<in-parameter-1>, |
Example |
[1] IFNULL(NULL,28) [2] IFNULL(100, 28) |
[1] NULLIF(28,28) |
Number of |
1 |
2 |
Number of |
1 |
0 |
If IN parameter is NULL |
Returns out-parameter value |
NA |
If IN parameter is NOT NULL |
Returns in-parameter value |
NA |
If IN parameter 1 is same/equal to IN parameter 2 |
NA |
Returns NULL |
If IN parameter 1 is not same/equal to IN parameter 2 |
NA |
Returns in-parameter-1 |
SQL Snowflake NULLIF vs IFNULL function |
Read More :
No comments:
Post a Comment