Listeners Who Beat Their Own Average
Problem
A podcast app records every listening session in the table `listen_sessions`, with the `listener_id`, the `episode_title`, and `minutes_played` for that session. A listener is considered *engaged* when they have at least 3 recorded sessions AND at least one of those sessions ran longer than that listener's own average session length. For every engaged listener, return their `listener_id`, their total number of sessions as `session_count`, and their average minutes per session as `avg_minutes` rounded to 2 decimals. Order the result by `avg_minutes` from highest to lowest, breaking ties by `listener_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
| listener_id | episode_title | minutes_played |
|---|---|---|
| 1 | Deep Sea Mysteries | 42 |
| 1 | City Soundscapes | 18 |
| 1 | Quiet Mornings | 60 |
Expected output
Your answer should return 2 rows with the columns listener_id, session_count, avg_minutes.
Starter code (SQL)
SELECT *
FROM listen_sessions;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