Streaming Subscribers on a Hot Streak
Problem
A music app records the days on which each subscriber opened the app.
Table: `Subscribers`
```text
+--------+---------+
| Column | Type |
+--------+---------+
| sub_id | int |
| handle | varchar |
+--------+---------+
sub_id is the primary key. handle is the subscriber's display name.
```
Table: `Opens`
```text
+----------+---------+
| Column | Type |
+----------+---------+
| sub_id | int |
| open_day | date |
+----------+---------+
This table may contain duplicate rows (a subscriber can open the app many times on the same day).
```
A subscriber is on a hot streak if they opened the app on five or more consecutive calendar days. Report the `sub_id` and `handle` of every such subscriber, ordered by `sub_id`.
Tables
Example rows — the live problem includes the full dataset.
| sub_id | handle |
|---|---|
| 1 | mara |
| 7 | devi |
| sub_id | open_day |
|---|---|
| 7 | 2021-04-30 |
| 1 | 2021-04-30 |
| 7 | 2021-05-01 |
Expected output
Your answer should return 1 row with the columns sub_id, handle.
Starter code (SQL)
SELECT *
FROM Subscribers;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