AnalystPath

Streaming Subscribers on a Hot Streak

SQLMediumMid level~15 min

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.

Subscribers
sub_idhandle
1mara
7devi
Opens
sub_idopen_day
72021-04-30
12021-04-30
72021-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

Related SQL questions