SQL Quest › SQL Interview Questions › Joins
Failure Rate Per Quality Type
What's the failure rate per quality grade? Higher-quality (H) parts should fail less in theory. Show type, total_units, failures, failure_rate_pct (rounded to 2 decimals). Order by failure_rate_pct descending.
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
products
| udi | product_id | type | tool_wear_min |
|---|---|---|---|
| 5640 | L52819 | L | 180 |
| 2171 | M17030 | M | 10 |
| 228 | L47407 | L | 168 |
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 |
Expected output: Confirms H quality fails less
Hint
JOIN products with failure_events on udi. failure_rate = SUM(machine_failure) * 100.0 / COUNT(*).
Concepts
SELECT JOIN GROUP BY Aggregation JOIN + GROUP BY
Practise the topic: SQL practice questions · JOIN practice · GROUP BY exercises
Related questions
Customers Who Never OrderedMedium · FreeAbove-Average Departments (Derived Table)Medium · FreeLEFT JOIN NULL Semantics: Inactive CustomersMedium · FreeManagement Hierarchy OverviewMedium · FreeCount Direct ReportsMedium · FreeCustomer Recency AnalysisMedium · Free
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