Given a table of ad impressions and a table of user clicks, write a query to find the click-through rate (CTR) grouped by country and device type on Snapchat.
CTR is the percentage of distinct impressions that received at least one click. Include impression groups with no clicks, and do not count duplicate clicks on the same impression more than once.
country, device_type, impression_count, clicked_impression_count, and ctr_percent.| Column | Type | Description |
|---|---|---|
| impression_idPK | INTEGER | Unique identifier for an ad impression |
| country | VARCHAR(100) | Country where the impression occurred |
| device_type | VARCHAR(50) | Device category for the impression |
| Column | Type | Description |
|---|---|---|
| click_idPK | INTEGER | Unique identifier for a click event |
| impression_id | INTEGER | Impression associated with the click, when available |