Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Operational Performance

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

Your question is SQL for Operational Performance. 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

Carvana Operations Managers need a location-level view of market operations performance. Write a PostgreSQL query using Carvana market locations, completed orders, and recorded order errors.

Use 2025-02-15 as the reporting date, and analyze completed orders whose completed_at falls within the preceding 30 days, including both boundary dates.

Requirements

  1. Return every market location, including locations with no qualifying completed orders.
  2. Calculate completed order count and average cycle time in minutes.
  3. Calculate error rate as the percentage of completed orders with at least one associated error. Return 0.00 when a location has no completed orders.
  4. Sort results alphabetically by location name.

Schema

market_locations
ColumnTypeDescription
location_idPKINTEGERUnique market location identifier
location_nameVARCHAR(100)Carvana market location name
orders
ColumnTypeDescription
order_idPKINTEGERUnique order identifier
location_idINTEGERMarket location handling the order
statusVARCHAR(20)Current order status
created_atDATEDate the order was created
completed_atDATEDate the order was completed
cycle_time_minutesINTEGEROperational cycle time in minutes
order_errors
ColumnTypeDescription
error_idPKINTEGERUnique error record identifier
order_idINTEGEROrder associated with the error
error_typeVARCHAR(50)Operational error category
Tablesmarket_locationsordersorder_errors
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results