Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
Dispatch Completion SQL Analysis
00:00
5 left

Dispatch Completion SQL Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to compare planned dispatches versus actual completed loads by day and region, and flag regions where completion rate fell below target.

Use the provided tables and include days with planned dispatches but no completed loads, as well as completed loads without plans.

Output

  1. One row per day and region with activity_date, region_name, planned_dispatches, completed_loads, completion_rate, and below_target
  2. Include all activity dates, calculate a zero completion rate when no dispatches were planned, and flag rates below the region target
  3. Order by activity_date, then region_name

Output details

  • Sort activity_date ascending, then region_name ascending.
  • Round completion_rate to exactly 4 decimal places.
  • Treat zero planned dispatches as completion_rate 0 and below_target TRUE.
  • Compare the unrounded completion ratio with the region target.
  • Exclude completed loads with a NULL region_id.
  • Omit activity rows whose region identifier has no matching region record.

Schema

regions
ColumnTypeDescription
region_idPKINTUnique regional identifier
region_nameVARCHAR(100)Region display name
target_completion_rateNUMERIC(5,4)Minimum acceptable completed-to-planned load ratio
planned_dispatches
ColumnTypeDescription
dispatch_idPKINTUnique planned dispatch identifier
dispatch_dateDATEDate on which the dispatch was planned
region_idINTRegion responsible for the planned dispatch
completed_loads
ColumnTypeDescription
load_idPKINTUnique completed load identifier
completion_dateDATEDate on which the load was completed
region_idINTRegion associated with the completed load
Tablesplanned_dispatchescompleted_loadsregions
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.