Snowflake Vs MS-SQL - Part 27 - Lateral Join

   


Lateral Join

Suppose you have two tables as below:



And you need to pull the data from both tables as below:



MS-SQL Server 

There are multiple approaches to achieve this. The common one is to use Inner Join. Another alternate is CROSS APPLY as below.


In Snowflakewe can not use CROSS APPLY as it does not support it. However, it provides an equivalent of it i.e. LATERAL JOIN. A lateral join behaves more like a correlated sub-query as below:



For more details, you can refer to the following LATERALJOIN


Note: However MS-SQL Server provides you OUTER APPLY additionally and

Snowflake does not have an equivalent of it, you may need to use LEFT JOIN.



    

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