Snowflake Vs MS-SQL - Part 47 - DUPLICATE_COUNT

           


DUPLICATE_COUNT

If you want to determine how many duplicate groups are present under any particular column. In the dataset below, Ontario presents 3 times, Saskatchewan presents 2 times, and LA only once. 

It shows Ontario & Saskatchewan are duplicate values, and we expect 2 as duplicate groups.

+----------+--------------+
| STORE_ID | Province     |
|----------+--------------+
|        1 | Ontario      |
|        2 | Saskatchewan |
|        3 | Ontario      |
|        4 | Ontario      |
|        5 | Saskatchewan |
|        6 | LA           |
+----------+--------------+

MS-SQL Server 

Using the aggregate function we can achieve as below:



In Snowflake, we can use a similar approach as above. However, Snowflake has a different Data metric function DUPLICATE_COUNT



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




Yogesh Shinde

LinkedInProfile

<<< Back Next >>>

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