Table Schema
Inspect
Table
| Column | Type |
|---|---|
| session_id | integer |
| user_id | integer |
| total_duration_seconds | integer |
Find sessions where total listening time exceeds 1 hour.
Table Schema
| Column | Type |
|---|---|
| session_id | integer |
| user_id | integer |
| total_duration_seconds | integer |
Sample Data
| session_id | user_id | total_duration_seconds |
|---|---|---|
| 1 | 101 | 1800 |
| 2 | 102 | 4000 |
| 3 | 103 | 2000 |
| 4 | 104 | 5000 |
| 5 | 105 | 1000 |
| session_id |
|---|
| 2 |
| 4 |
SQL Editor
| session_id |
|---|
| 2 |
| 4 |
Hints
Solution
Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.
SELECT session_id FROM sessions WHERE total_duration_seconds > 3600;
Explanation
Read the expected output columns to determine the final grain.
Aggregate or rank the input rows to calculate the requested metric.
Filter, sort, and alias the final columns to match the output.
Related Questions