Top Reviewer and Best Episode
Problem
Table: `Episode`
```text
+------------+---------+
| Column | Type |
+------------+---------+
| episode_id | int |
| episode | varchar |
+------------+---------+
episode_id is the primary key.
```
Table: `Listener`
```text
+-------------+---------+
| Column | Type |
+-------------+---------+
| listener_id | int |
| handle | varchar |
+-------------+---------+
listener_id is the primary key.
```
Table: `Review`
```text
+-------------+---------+
| Column | Type |
+-------------+---------+
| episode_id | int |
| listener_id | int |
| stars | int |
| posted_on | date |
+-------------+---------+
Each row is one listener's star score for one episode on a date.
```
Return a single column named `result` containing exactly two rows:
1. The `handle` of the listener who posted the **most reviews** overall. Break ties by the handle that is alphabetically smallest.
2. The `episode` with the **highest average score** among reviews posted in **April 2021** (`2021-04-01` to `2021-04-30`). Break ties by the episode name that is alphabetically smallest.
**Example**
```text
If 'mara_k' posted the most reviews, and episode 'Tidewater' had the best
April average, the output is two rows: 'mara_k' then 'Tidewater'.
```
Tables
Example rows — the live problem includes the full dataset.
| episode_id | episode |
|---|---|
| 1 | Tidewater |
| 2 | Static Bloom |
| listener_id | handle |
|---|---|
| 1 | mara_k |
| 2 | devon |
| episode_id | listener_id | stars | posted_on |
|---|---|---|---|
| 1 | 1 | 5 | 2021-04-03 |
| 2 | 1 | 4 | 2021-04-10 |
| 1 | 2 | 5 | 2021-04-12 |
Expected output
Your answer should return 2 rows with the columns result.
Starter code (SQL)
SELECT *
FROM Episode;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