App Click-Through Rate Analysis
Meta 👶 Easy SQL
Beginner Mode

Objective

Write a SQL query to calculate the click-through rate (CTR) for each app based on 2022 events data.

Table Schema:

  • events
Column Type Description
event_id INTEGER Unique identifier for each event
app_id INTEGER ID of the app
event_type VARCHAR Type of event ('impression' or 'click')
event_date DATETIME Date and time when the event occurred

Task Requirements:

  • Filter only events from the year 2022
  • Calculate CTR as (clicks / impressions) * 100 for each app
  • Round the CTR to 2 decimal places
  • Sort results by app ID in ascending order

Output columns: app_id, ctr

Examples

Example 1:

Input:

events
app_idevent_dateevent_idevent_type
1012022-01-15 10:00:001impression
1012022-01-15 10:05:002click
1012022-01-16 11:00:003impression
1022022-02-10 09:00:004impression
1022022-02-10 09:30:005impression
1022022-02-10 10:00:006click

Output:
app_idctr
10150
10250
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →