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:
Yogesh Shinde
Comments
Post a Comment