๐ฌ Streaming Service Analytics
You're working as a data analyst for a popular streaming service! Your company wants to understand subscriber engagement patterns to optimize their business strategy.
You have access to two important datasets:
- Subscriptions Table: Contains account subscription periods with
account_id,start_date, andend_date - Streams Table: Records every streaming session with
session_id,account_id, andstream_date
Your mission: Find how many accounts purchased a subscription in 2021 but never actually used the service (had zero streaming sessions).
This metric is crucial for understanding subscription abandonment - customers who pay but don't engage with the platform. The marketing team needs this data to improve user onboarding and reduce churn!
Return a single number representing the count of inactive subscribers from 2021.
Input & Output
Visualization
Time & Space Complexity
Single pass through subscriptions (n) and streams (m) with hash join
Space for hash table of smaller relation (k accounts)
Constraints
- 1 โค account_id โค 106
- start_date < end_date
- Dates are in format YYYY-MM-DD
- session_id is unique in Streams table
- account_id in Streams is a foreign key from Subscriptions