AnalystPath

Players Not Recruited by Coach #4

SQLEasyJunior level~15 min

Problem

Table: `Player`

```text
+-------------+---------+
| Column | Type |
+-------------+---------+
| player_id | int |
| player_name | varchar |
| recruiter_id| int |
+-------------+---------+
player_id is the primary key. recruiter_id is the player_id of whoever recruited this player, or NULL if they joined on their own.
```

Find the `player_name` of every player who is **either** recruited by someone whose id is **not** `4`, **or** was not recruited by anyone. Return the rows in any order.

**Example**

```text
Player:
+-----------+-------------+--------------+
| player_id | player_name | recruiter_id |
+-----------+-------------+--------------+
| 1 | Mira | null |
| 4 | Sol | null |
| 2 | Ravi | 4 |
| 3 | Toni | 1 |
| 5 | Uri | 4 |
+-----------+-------------+--------------+

Output:
+-------------+
| player_name |
+-------------+
| Mira |
| Sol |
| Toni |
+-------------+
```

Ravi and Uri were recruited by player 4, so they are excluded.

Tables

Example rows — the live problem includes the full dataset.

Player
player_idplayer_namerecruiter_id
1Mira
4Sol
2Ravi4

Expected output

Your answer should return 3 rows with the columns player_name.

Starter code (SQL)

SELECT *
FROM Player;

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