SQL Quest › SQL Interview Questions › Aggregation & Grouping
Failure Count by Mode
How many failures occurred per failure mode? The flags twf/hdf/pwf/osf/rnf are 0/1 in failure_events. Show one row per mode: twf_count, hdf_count, pwf_count, osf_count, rnf_count, total_failures.
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". Free accounts get 10 free challenge solves, and this can be one of them.
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 |
Expected output: Failure counts per mode
Hint
Concepts
SELECT Aggregation SUM
Practise the topic: SQL practice questions · GROUP BY exercises
Read the concept: SQL GROUP BY tutorial
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