Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Bucket Records with CASE

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

Your question is Bucket Records with CASE. 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

The Airbus Helicopters HCare maintenance quality dashboard needs a consistent classification for inspection scores. Write a PostgreSQL query using CASE WHEN to bucket each inspection record.

Requirements

  1. Return the inspection ID, helicopter model, original score, and a score_category.
  2. Classify scores as Critical below 50, Review from 50 through 79, Acceptable from 80 through 100, Invalid Score outside that range, and Not Scored when the score is NULL.
  3. Order the results by inspection_id ascending.

Schema

inspection_records
ColumnTypeDescription
inspection_idPKINTEGERUnique inspection identifier
helicopter_modelVARCHAR(50)Airbus Helicopters model inspected
inspection_scoreINTEGERInspection score, normally from 0 to 100
inspection_statusVARCHAR(20)Current inspection workflow status
Tablesinspection_records
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results