Snowflake Vs MS-SQL - Part 17 - Compare Data from Two Tables

 


Compare Data from Two Tables

Sometimes you encounter a problem and must compare data from two tables. It is a hard and time-consuming task, but if you have a table with a comparable structure, the query will be simple.


MS-SQL Server 

There are several approaches: you can use JOIN and include all columns in the WHERE clause. Another option could be to concatenate all columns and then compare them. 

For more details, you can refer to the following LINK.

A simple way is to write an EXCEPT query as below.




In Snowflake, the above EXCEPT query works. However, we can use the Aggregate Function HASH_AGG. It returns an aggregate signed 64-bit hash value. If you compare the return value of both tables as below:




Not only this, if you want then you can compare the two columns as well.


For more details, you can refer to the following LINK.



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