SQL Quest › SQL Interview Questions › Joins
Failure Mode Catalog Join
Build a unified failure event log: for each failure mode (TWF/HDF/PWF/OSF/RNF), output rows of (udi, mode_code, mode_name, fmea_category) by joining failure_events flags to failure_modes lookup. UNION ALL the 5 modes together. Show top 30 by udi.
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".
Schema
failure_events
| udi | machine_failure | twf | hdf | pwf | osf | rnf |
|---|---|---|---|---|---|---|
| 5640 | 0 | 0 | 0 | 0 | 0 | 1 |
| 2171 | 0 | 0 | 0 | 0 | 0 | 0 |
| 228 | 0 | 0 | 0 | 0 | 0 | 0 |
failure_modes
| code | name | fmea_category | description |
|---|---|---|---|
| TWF | Tool Wear Failure | Mechanical | Tool wear exceeded threshold (~200 minutes) |
| HDF | Heat Dissipation Failure | Thermal | Air-process temperature differential too low + high rotational speed |
| PWF | Power Failure | Electrical | Required process power outside [3500, 9000] W envelope |
Expected output: One row per (udi, fired-mode)
Hint
Concepts
SELECT JOIN UNION ALL Set Operations
Practise the topic: SQL practice questions · JOIN practice · CTE practice
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test