Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Aggregate by Category

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

Your question is Aggregate by Category. Start with the requirements and the one table 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

Airbus Helicopters uses Skywise maintenance data to monitor completed maintenance activity and associated repair costs. Write a PostgreSQL query that summarizes completed maintenance events by component category.

Requirements

  1. Return one row per component_category with the number of completed events and the total repair cost.
  2. Order the results by total repair cost from highest to lowest.

Schema

helicopter_maintenance_events
ColumnTypeDescription
event_idPKINTEGERUnique maintenance event identifier
component_categoryVARCHAR(40)Maintained helicopter component category
statusVARCHAR(20)Current maintenance event status
repair_costNUMERIC(12,2)Repair cost in euros, which may be missing
Tableshelicopter_maintenance_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results