I need to lookup URLs with the same 'productid=' in Big Query but they may have a different path based on a redesign and new URL format. I'm looking to SUM the clicks for the specific ID if possible.
Example:
- /path-a/productid=12345 (clicks 10)
- /path-b/productid=12345 (clicks 15)
- /path-c/productid=12345 (clicks 2)
productid=12345 = 27 clicks
I need to match the "productid=" number but unsure of the regex. There's around 9,000 DISTINCT IDs and the integers can range from one digits to six digits.
SELECT path, sum(clicks) as clicks, sum(impressions) as impressions
FROM `ecommerce_table`
WHERE DATE(_PARTITIONTIME) >= "2021-04-01"
AND path LIKE '/%/productid=%'
GROUP BY path
ORDER BY clicks DESC