Snowflake Vs MS-SQL - Part 77 - Remove Duplicates From String

          


Remove Duplicates From String

Suppose you have a string that contains values separated by a delimiter, and you have to remove those duplicates.


-- Actual String
'A, B, C, a, b'

-- Expected String
'A, B, C'


MS-SQL Server 

We can achieve it by using functions like STRING_AGG & STRING_SPLIT:



In Snowflake, we can use a similar approach by using LISTAGG & SPLIT_TO_TABLE, as below





For more details, refer to LISTAGG & 
SPLIT_TO_TABLE.


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