SQL Quest › SQL Interview Questions › Aggregation & Grouping

Failure Count by Mode

EasyFreeQuerying BasicsAggregation & Grouping

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

udimachine_failuretwfhdfpwfosfrnf
5640000001
2171000000
228000000

Expected output: Failure counts per mode

Hint

SUM(twf), SUM(hdf), etc. SUM of 0/1 columns gives the count.

Concepts

SELECT Aggregation SUM

Practise the topic: SQL practice questions · GROUP BY exercises

Read the concept: SQL GROUP BY tutorial

Related questions

Quality Grade DistributionEasy · FreeAverage Sensor ReadingsEasy · FreeQuality Grades With 100+ ProductsEasy · FreeMonthly Spend Per AccountEasy · FreeChargeback Reason Codes: Resolved and Still OpenEasy · FreeSpend by Day of WeekEasy · 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