Tuition Collected by Each Tutor
Problem
A tutoring center tracks tutors, the students assigned to each tutor, and the tuition payments those students make.
The `Tutor` table lists every tutor. The `Student` table maps each student to the tutor who teaches them. The `Payment` table records the amount of each tuition payment a student makes.
Write a query that reports, for every tutor, the total tuition collected from all of their students. A tutor who has no students, or whose students have made no payments, must still appear with a total of `0`.
Return the result in any order. The result columns are `tutor_id`, `tutor_name`, and `collected`.
Tables
Example rows — the live problem includes the full dataset.
| tutor_id | tutor_name |
|---|---|
| 11 | Dana |
| 12 | Omar |
| 13 | Priya |
| student_id | tutor_id |
|---|---|
| 101 | 11 |
| 102 | 11 |
| 103 | 12 |
| payment_id | student_id | amount |
|---|---|---|
| 1 | 102 | 320 |
| 2 | 101 | 145 |
| 3 | 103 | 410 |
Expected output
Your answer should return 3 rows with the columns tutor_id, tutor_name, collected.
Starter code (SQL)
SELECT *
FROM Tutor;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