SQL QuestSQL Interview Questions › Subqueries & CTEs

Failure Rate by Torque Bucket

HardProQuerying BasicsSubqueries & CTEsJoinsConditional LogicAggregation & Grouping

Bucket units by torque into 'Low' (< 30), 'Medium' (30-50), 'High' (>= 50) Nm. Compute failure rate per bucket per quality grade. Show type, torque_bucket, unit_count, failures, failure_rate_pct. Order by type, torque_bucket.

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

operational_data

udiair_temp_kprocess_temp_krotational_speed_rpmtorque_nm
5640302.6312.1166828.7
2171299.4309.1150043.3
228298.3308.5153936.1

failure_events

udimachine_failuretwfhdfpwfosfrnf
5640000001
2171000000
228000000

Expected output: Where do failures cluster?

Hint

This is a Pro challenge — the hint, the step-by-step tutor and the reference solution open in the app.

Concepts

SELECT CTE JOIN CASE GROUP BY Multi-CTE

Practise the topic: SQL practice questions · CTE practice · JOIN practice · CASE WHEN practice · GROUP BY exercises · Advanced SQL interview questions

Related questions

Cumulative Distinct Customers Over TimeHard · FreeRunning Total RevenueHard · FreeYear-over-Year GrowthHard · Free7-Day Rolling Revenue AverageHard · FreeMulti-CTE Revenue PipelineHard · FreeWealthy Survivor ProfileHard · Pro

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