URL TABLE:
| URL PATH |
| www.abc.com/123 |
| www.abc.com/234 |
| www.abc.com/435 |
TRAFFIC TABLE:
| ID | URL PATH | COUNTRY | TIMESTAMP |
| 1 | www.abc.com/123 | US | 3/31/2022 10:00 |
| 1 | www.abc.com/gb/123 | GB | 3/31/2022 10:00 |
| 1 | www.abc.com/de/123 | DE | 3/31/2022 10:00 |
| 4 | www.abc.om/xyz | US | 3/31/2022 10:00 |
| 4 | www.abc.om/asd | DE | 3/31/2022 10:00 |
OBJECTIVE:
Hello, I have two tables. 1) URL Table contains a list of URLs specific to US Country and 2) Traffic Table containing all event timestamps for all countries on the website.
I want to first get the product ID that matches the URL PATH in the URL TABLE then get the aggregate count of that product ID. With the above example, the desired outcome would be:
| ID | COUNT |
| 1 | 3 |
ID 4 wouldn't appear because none of it's corresponding URL appears in the URL table.
www.abc.com/123 matches ID 1 in the traffic table and there are three rows associated with this ID hence a value of 3.
I've tried doing some LEFT JOINs but haven't had much luck.New to SQL. Would appreciate any help! Also using the Snowflake UI to create this query.