Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Server Components by Failures

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

Your question is Top Server Components by Failures. Start with the requirements and the three 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 operations team wants to identify the best-performing server components for each month. Write a PostgreSQL query that calculates monthly failure rates while accounting for shipment volume, then returns the top three components per month.

Requirements

  1. Aggregate shipped units and failed units by component and calendar month.
  2. Include components with shipments but no recorded failures, treating their failed-unit count as zero.
  3. Exclude months where total shipment volume is zero and rank components by the lowest failure rate, then highest shipment volume.
  4. Return the top three ranked components for January and February 2025.

Schema

components
ColumnTypeDescription
component_idPKINTUnique component identifier
component_nameVARCHAR(100)Supermicro component name
component_typeVARCHAR(50)Component category
statusVARCHAR(20)Component lifecycle status
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment record identifier
component_idINTComponent included in the shipment
shipment_dateDATEDate units were shipped
units_shippedINTNumber of units shipped
failures
ColumnTypeDescription
failure_idPKINTUnique failure record identifier
component_idINTComponent associated with the failure
failure_dateDATEDate the failure was reported
units_failedINTNumber of failed units in the record
Tablescomponentsshipmentsfailures
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results