AnalystPath

Players Whose Coach Left the Roster

SQLEasyJunior level~15 min

Problem

Table: `roster`

| Column Name | Type |
|---|---|
| player_id | int |
| full_name | varchar |
| coach_id | int |
| stipend | int |

`player_id` is the primary key. Each row gives a player, their monthly stipend, and the `player_id` of their coach (a coach is also listed as a player). Some players have no coach (`coach_id` is NULL).

Return the `player_id` of every player whose stipend is strictly below `2000` and whose coach is no longer on the roster. A coach is no longer on the roster when their id does not appear as any `player_id`. Order the result by `player_id` ascending.

Tables

Example rows — the live problem includes the full dataset.

roster
player_idfull_namecoach_idstipend
1Ana5000
2Beto11500
3Cleo91200

Expected output

Your answer should return 2 rows with the columns player_id.

Starter code (SQL)

SELECT *
FROM roster;

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