App Ad Click-Through Rate
Problem
**[Asked at Facebook/Meta]**
An events table logs every time a user either *views* (impression) or *clicks* an ad
inside a mobile app. Compute the **click-through rate (CTR)** for each app:
CTR = 100.0 × (number of clicks) / (number of impressions)
Return `app_id` and `ctr` rounded to **2 decimal places**. Only include apps that had
at least one impression in 2022. Order by `app_id`.
Tables
Example rows — the live problem includes the full dataset.
ad_events
| event_id | app_id | event_type | -- |
|---|
Expected output
Your answer should return 3 rows with the columns app_id, ctr.
Starter code (SQL)
SELECT *
FROM ad_events;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock