Fully Certified Staff
Problem
A company tracks training in three tables: staff(staff_id, full_name, team), modules(module_id, title, hours, team), and attempts(staff_id, module_id, term, result). Every team has a set of required modules (the modules whose team matches the staff member's team). Find every staff member who has a passing attempt (result = 'Pass') in every required module for their team. A person counts only if they passed all of their team's modules with no module left unattempted or failed. Order the result by staff_id.
Tables
Example rows — the live problem includes the full dataset.
| staff_id | full_name | team |
|---|---|---|
| 1 | Nadia | Security |
| 2 | Omar | Security |
| 3 | Priya | Logistics |
| module_id | title | hours | team |
|---|---|---|---|
| 101 | Threat Modelling | 3 | Security |
| 102 | Incident Response | 3 | Security |
| 103 | Warehouse Safety | 4 | Logistics |
| staff_id | module_id | term | result |
|---|---|---|---|
| 1 | 101 | Q1 2024 | Pass |
| 1 | 102 | Q1 2024 | Pass |
| 2 | 101 | Q1 2024 | Fail |
Expected output
Your answer should return 2 rows with the columns staff_id.
Starter code (SQL)
SELECT *
FROM staff;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