Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Monthly Failure Rates by Component

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Monthly Failure Rates by Component. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Supermicro’s hardware analytics team monitors component validation tests across server systems. Write a PostgreSQL query that calculates monthly failure rates by component and identifies the worst-performing components within each month.

Requirements

  1. Include only completed tests with a test_status of PASS or FAILED; exclude inconclusive or missing statuses.
  2. Calculate total completed tests, failed tests, and failure rate as failed_tests / total_tests * 100, rounded to two decimal places.
  3. Rank components within each month from highest to lowest failure rate using a window function. Preserve equal ranks for equal rates.
  4. Return results ordered by month, failure rate descending, and component ID.

Schema

component_catalog
ColumnTypeDescription
component_idPKINTUnique component identifier
component_nameVARCHAR(80)Supermicro component name
component_familyVARCHAR(50)Component category
component_test_events
ColumnTypeDescription
test_idPKINTUnique validation test identifier
component_idINTTested component identifier
tested_atTIMESTAMPTest completion timestamp
test_statusVARCHAR(20)Validation result status
Tablescomponent_catalogcomponent_test_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results