Uninterrupted Study Sessions
Problem
A focus app records each user's study sessions and any notification pings sent to them.
```
StudySession
+------------+------+
| Column | Type |
+------------+------+
| session_id | int |
| user_id | int |
| start_min | int |
| end_min | int |
+------------+------+
session_id is the primary key. start_min/end_min are minute offsets within a day.
Ping
+----------+------+
| Column | Type |
+----------+------+
| ping_id | int |
| user_id | int |
| at_min | int |
+----------+------+
ping_id is the primary key. at_min is the minute the ping fired.
```
Report the `session_id` of every study session during which the same user received **no** ping. A ping interrupts a session if it fired at any minute from `start_min` to `end_min`, inclusive.
Return the result in any order.
Tables
Example rows — the live problem includes the full dataset.
| session_id | user_id | start_min | end_min |
|---|---|---|---|
| 1 | 1 | 1 | 5 |
| 2 | 1 | 15 | 23 |
| 3 | 2 | 10 | 12 |
| ping_id | user_id | at_min |
|---|---|---|
| 1 | 1 | 5 |
| 2 | 2 | 17 |
| 3 | 12 | 20 |
Expected output
Your answer should return 3 rows with the columns session_id.
Starter code (SQL)
SELECT *
FROM StudySession;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