I got a table which contains URLs and some other columns, for example dates. The URLs contain IDs, separated by different values. What the IDs have in common is that they contai
try this one
select
date,
ids_count,
count(*) as combinations_count
from
( select
date,
url,
regexp_extract_all(
concat(
regexp_replace(url, r'[[:punct:]]', '~~'), '~'),
r'~(\d+)~') as ids,
array_length(
regexp_extract_all(
concat(
regexp_replace(url, r'[[:punct:]]', '~~'), '~'),
r'~(\d+)~')) as ids_count
from
unnest(array[ struct(date'1999-01-01' as date, 'https://www.example.com/category1/subcategory1/71347983~7275798_fui~85092374238590235.......' as url),
struct(date'1999-01-02', 'https://www.example.com/category1/subcategory2/71347983_7275798/85092374238590235~773429834.......'),
struct(date'1999-01-01', 'https://www.example.com/category1/subcategory2/71347983_23235~773429834')])
)
group by
1, 2