Snowflake Vs MS-SQL - Part 39 - EQUAL_NULL

       


EQUAL_NULL

Your data is as below, if you make self join then it should return 3 records instead of 2 records by considering NULL. 

Expected Output:


MS-SQL Server 

You can achieve this by using the ISNULL function. 



In Snowflake we can use the similar function IFNULL.



However, Snowflake has another two approaches 
which give you the same result.

Function EQUAL_NULL 


Operator 
IS [ NOT ] DISTINCT FROM 

  • EQUAL_NULL is a function, while IS [ NOT ] DISTINCT FROM is an operator.
  • EQUAL_NULL is used as a function call, while IS [ NOT ] DISTINCT FROM is used as part of a SQL expression.
  • EQUAL_NULL: A function to compare two values, treating NULL as equal.
  • IS [ NOT ] DISTINCT FROM: An operator to compare two values, treating NULL as equal or distinct based on the context.




For more details, you can refer to the following EQUAL_JOIN or IFNULL or IS_DISTINCT_FROM .





Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP