Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
SQL Top Delayed Distribution Centers
00:00
5 left

SQL Top Delayed Distribution Centers

MediumSQL · PostgreSQL

Problem

Walmart's supply chain team wants to identify distribution centers with the highest average shipment delays during the previous calendar quarter. Write a SQL query that calculates the average recorded delay for each eligible distribution center and returns the three centers with the highest averages.

Output

  1. One row per distribution center, with columns distribution_center_id, center_code, center_name, and average_delay_minutes
  2. Include only shipments from the previous calendar quarter and ignore shipments whose delay is NULL
  3. Return the three centers with the highest average delay, ordered from highest to lowest average; break ties by ascending distribution_center_id

Schema

distribution_centers
ColumnTypeDescription
distribution_center_idPKINTUnique distribution center identifier
center_codeVARCHAR(20)Operational distribution center code
center_nameVARCHAR(100)Distribution center name
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
distribution_center_idINTDistribution center handling the shipment
shipment_dateDATEShipment processing date
delay_minutesDECIMAL(10,2)Shipment delay in minutes, nullable when not recorded
Tablesdistribution_centersshipments
Interviewer

Your question is SQL Top Delayed Distribution Centers. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.