SQL QuestSQL Interview Questions › Joins

Failure Rate Per Quality Type

MediumFreeQuerying BasicsJoinsAggregation & Grouping

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

udiproduct_idtypetool_wear_min
5640L52819L180
2171M17030M10
228L47407L168

failure_events

udimachine_failuretwfhdfpwfosfrnf
5640000001
2171000000
228000000

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