An advertising analytics service measures ad performance using Click-Through Rate (CTR). CTR is defined as: `CTR = (Total Clicks / Total Impressions) * 100` Write a SQL query joining `campaign_ads` with `ad_events` to return each ad's `ad_id` and its calculated `ctr` percentage rounded to 2 decimal places. Sort the results by `ad_id` ascending. Edge cases tested: - If an ad received 0 impressions, return a CTR of 0.00 (division by zero must not throw an error). - An ad might have impressions but 0 clicks (CTR is 0.00). - Results must be rounded to exactly 2 decimal places.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.