I have a table called phone_numbers which can be in length from 10-12 digits. I am using Snowflake UI and would like to get the the number of unique values for every phone number. For instance, 9999999999 should have a value of 1. 1234567890 should have a value of 10.
Thanks in advance!
I have tried some regex functions like the following.
SELECT phone_number,
LENGTH(phone_number) -
LENGTH(REGEXP_REPLACE(phone_number, '[0-9]', '')) AS unique_digit_count
FROM phone_numbers
You can add commas between all the characters using
regexp_replaceand then usesplit_to_table, and then count the number of distinct values per phone number.Output: