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
Rolling 30-Day Latency SQL
00:00
5 left

Rolling 30-Day Latency SQL

HardSQL · PostgreSQL

Problem

Write a SQL query to calculate the rolling 30-day average delivery latency across regional hubs, broken down by vendor tier.

Use completed deliveries only, where latency is the elapsed time from shipped_at to delivered_at. Each 30-day period includes the current delivery date and the preceding 29 calendar days.

Output

  1. One row per hub, vendor tier, and delivery date.
  2. Return hub_name, region, vendor_tier, delivery_date, and rolling_30_day_avg_latency_hours.
  3. Include only non-null vendor tiers and completed deliveries. Order by region, hub name, vendor tier, and delivery date ascending.

Schema

regional_hubs
ColumnTypeDescription
hub_idPKINTUnique regional hub identifier
hub_nameVARCHAR(100)Regional hub name
regionVARCHAR(100)Geographic region containing the hub
vendors
ColumnTypeDescription
vendor_idPKINTUnique vendor identifier
vendor_nameVARCHAR(100)Vendor name
tierVARCHAR(30)Vendor service tier
deliveries
ColumnTypeDescription
delivery_idPKINTUnique delivery identifier
hub_idINTRegional hub handling the delivery
vendor_idINTVendor responsible for the delivery
shipped_atTIMESTAMPShipment start timestamp
delivered_atTIMESTAMPDelivery completion timestamp
Tablesregional_hubsvendorsdeliveries
Interviewer

Your question is Rolling 30-Day Latency SQL. Start with the requirements and the three 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.