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
Store KPI SQL Analysis
00:00
5 left

Store KPI SQL Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze Mars store performance by joining sales, inventory, and labor tables, and return the key KPIs by store and week.

Use the provided tables and include weeks represented in any source table. Missing source values should not remove a store-week from the results.

Output

  1. One row per store and week, with store_id, week_start, net_sales, units_sold, avg_inventory_units, labor_hours, labor_cost, and sales_per_labor_hour.
  2. Include all store-weeks present in any source table, treating missing additive measures as zero where appropriate and returning NULL when labor hours are zero or unavailable.
  3. Order by store_id, then week_start.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
store_idINTMars store identifier
sale_dateDATETransaction date
units_soldINTUnits sold in the transaction
net_salesDECIMAL(12,2)Net sales amount after discounts and returns
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
store_idINTMars store identifier
inventory_dateDATEInventory snapshot date
units_on_handINTUnits available at the snapshot time
inventory_valueDECIMAL(12,2)Estimated inventory value
labor
ColumnTypeDescription
labor_idPKINTUnique labor record identifier
store_idINTMars store identifier
labor_dateDATEShift or labor record date
labor_hoursDECIMAL(8,2)Hours worked
labor_costDECIMAL(12,2)Labor cost for the record
Tablessalesinventorylabor
Interviewer

Your question is Store KPI SQL Analysis. 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.