'Snowflake - REMOVE duplicated words/strings within a string in snowflake
i have this code that works in oracle, to a certain degree
with data(str) as (
select '3|BUTE PLACE|BUTE PLACE' from dual union all
select '3 BUTE PLACE BUTE PLACE' from dual union all
select '3 BUTE PLACE BUTE-PLACE' from dual)
select str, rtrim(str_new, ' ') new_str
from data
model
partition by (rownum rn)
dimension by (0 dim)
measures(str, str||' ' str_new)
rules
iterate(10000) until (str_new[0] = previous(str_new[0]))
(str_new[0]=regexp_replace(str_new[0],'(^| )([^ ]+ )(.*? )?\2+','\1\2\3'))
what i'm trying to figure out is how to use this code in snowflake where my address line is | separated and i want to be able to turn '3|BUTE PLACE|BUTE PLACE' into '3|BUTE PLACE' for the purpose of address matching.
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|