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.
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 :