Email Engagement

ASKED IN INTERVIEW
4pts
Hub Spot

Problem Statement

Calculate the open rate for all HubSpot email campaigns.

Rules:

  • Output columns: campaign_id, open_rate.
  • open_rate = (Total unique opens / Total unique sends) * 100.
  • Round results to 2 decimal places.
  • Sort by open_rate in descending order.
Tests your understanding of
Aggregation, Case Logic and Mathematical Operations

Input Tables

campaigns
campaign_id(INTEGER)campaign_name(VARCHAR)
1New Year Sale
2Product Launch
3Follow-up
email_events
event_id(INTEGER)campaign_id(INTEGER)user_id(INTEGER)event_type(VARCHAR)
11101send
21102send
31101open
42103send
52104send
62103open
72104open
83105send

Expected Output

campaign_id(INTEGER)open_rate(DECIMAL)
2100
150
30

Tags

MediumASKED IN INTERVIEWAggregationCase LogicMathematical Operations
15-20 min
51%

Hints