Mid-Chain Mentors
Problem
A company runs a mentorship program where one person mentors another.
```
Mentorship
+--------+---------+
| Column | Type |
+--------+---------+
| mentor | varchar |
| mentee | varchar |
+--------+---------+
(mentor, mentee) is the primary key. Each row means `mentor` mentors `mentee`.
```
A **mid-chain mentor** is a person who mentors at least one mentee AND is themselves mentored by someone (their name appears in the `mentee` column too).
Return each mid-chain mentor as `mentor`, along with the number of distinct people they mentor as `mentee_count`. Order the result by `mentor`.
Tables
Example rows — the live problem includes the full dataset.
| mentor | mentee |
|---|---|
| Priya | Marco |
| Marco | Sven |
| Marco | Tariq |
Expected output
Your answer should return 2 rows with the columns mentor, mentee_count.
Starter code (SQL)
SELECT *
FROM Mentorship;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