Mentors With At Least Five Mentees
Problem
Table: `Researcher`
```text
+-------------+---------+
| Column | Type |
+-------------+---------+
| res_id | int |
| full_name | varchar |
| lab | varchar |
| mentor_id | int |
+-------------+---------+
res_id is the primary key. mentor_id is the res_id of this researcher's mentor, or NULL if they have no mentor. Nobody mentors themselves.
```
Find every researcher who is the direct mentor of **at least five** other researchers. Return their `full_name` in any order.
**Example**
```text
Researcher:
+--------+---------+-----+-----------+
| res_id | full_name | lab | mentor_id |
+--------+---------+-----+-----------+
| 1 | Noa | X | NULL |
| 2 | Eli | X | 1 |
| 3 | Tal | X | 1 |
| 4 | Roi | X | 1 |
| 5 | Mia | X | 1 |
| 6 | Ari | Y | 1 |
+--------+---------+-----+-----------+
Output:
+-----------+
| full_name |
+-----------+
| Noa |
+-----------+
```
Noa mentors five researchers (Eli, Tal, Roi, Mia, Ari), so she qualifies.
Tables
Example rows — the live problem includes the full dataset.
| res_id | full_name | lab | mentor_id |
|---|---|---|---|
| 1 | Noa | X | |
| 2 | Eli | X | 1 |
| 3 | Tal | X | 1 |
Expected output
Your answer should return 1 row with the columns full_name.
Starter code (SQL)
SELECT *
FROM Researcher;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