Google Search tracks every time a result is shown (Impression) and every time it is clicked (Click). To evaluate ranking effectiveness, we need to see the CTR for the top 10 positions.
Write an SQL query to calculate the CTR for each position.
| search_id(INTEGER) | search_position(INTEGER) |
|---|---|
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 2 | 2 |
| 3 | 1 |
| 3 | 10 |
| 4 | 1 |
| search_id(INTEGER) | search_position(INTEGER) |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 10 |
| search_position(INTEGER) | total_impressions(INTEGER) | total_clicks(INTEGER) | ctr(DECIMAL) |
|---|---|---|---|
| 1 | 4 | 2 | 50 |
| 2 | 2 | 0 | 0 |
| 10 | 1 | 1 | 100 |