Snowflake Vs MS-SQL - Part 70 - UNION By Name

       



UNION By Name

Sometimes, we have to combine data from multiple tables. In this case, we can use UNION. However, the catch is that the order of the columns should be the same.


MS-SQL Server 

We can achieve this by using UNION as below:




In Snowflake, we can use the same query as above; however, we have to use the same column order in the select clause. However, we can use UNION BY Name as below. The order of the columns in the select clause does not matter.




NOTE: Similarly, you can use UNION ALL BY NAME.


For more details, you can refer to the following: UNION
.



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