Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Compute 30-Day Market Operations Performance
00:00
5 left

Compute 30-Day Market Operations Performance

MediumSQL · PostgreSQL

Problem

Operations Managers at a company need a location-level view of market operations performance. Write a PostgreSQL query using 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.

Output details

  • Return columns in this order: location_name, completed_orders, average_cycle_time_minutes, and error_rate_percent.
  • Round average_cycle_time_minutes and error_rate_percent to two decimal places.
  • Return NULL for average_cycle_time_minutes when a location has no qualifying completed orders.
  • Keep separate market-location rows even when multiple locations share the same 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
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.