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 Monthly Location KPIs
00:00
5 left

SQL Monthly Location KPIs

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate monthly operational KPIs by location, including total volume, average cycle time, and month-over-month change.

Use completed operational records and exclude records without a valid location. Cycle time is the elapsed time between started_at and completed_at in minutes.

Output

  1. One row per location and calendar month with completed activity.
  2. Columns: location_name, month, total_volume, avg_cycle_time_minutes, mom_volume_change, and mom_volume_change_pct.
  3. Show NULL month-over-month values when no prior month exists, and order by location name and month.

Schema

locations
ColumnTypeDescription
location_idPKINTUnique operational location identifier
location_nameVARCHAR(100)Display name of the operational location
regionVARCHAR(50)Geographic region containing the location
operational_events
ColumnTypeDescription
event_idPKINTUnique operational event identifier
location_idINTLocation associated with the event
statusVARCHAR(20)Current event status
started_atTIMESTAMPTimestamp when operational processing began
completed_atTIMESTAMPTimestamp when operational processing completed
Tableslocationsoperational_events
Interviewer

Your question is SQL Monthly Location KPIs. 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.