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

Store Performance SQL Analysis

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze store performance by joining sales, inventory, and labor tables to calculate revenue, gross margin, and labor cost by store and week at Advance Auto Parts. Include store-weeks represented in any source table, treating missing measures as zero where appropriate.

Output

  1. One row per store and week, with store_id, week_start, revenue, gross_margin, labor_cost, and average_inventory_units.
  2. Include all store-weeks found in sales, inventory, or labor data, ordered by store_id, then week_start.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
store_idINTAdvance Auto Parts store identifier
sale_dateDATETransaction date
unitsINTUnits sold
unit_priceDECIMAL(10,2)Selling price per unit
unit_costDECIMAL(10,2)Product cost per unit
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory observation identifier
store_idINTAdvance Auto Parts store identifier
week_startDATEStart date of the inventory week
inventory_unitsINTUnits recorded in inventory
labor
ColumnTypeDescription
labor_idPKINTUnique labor record identifier
store_idINTAdvance Auto Parts store identifier
week_startDATEStart date of the labor week
labor_hoursDECIMAL(8,2)Paid labor hours
hourly_rateDECIMAL(8,2)Average hourly labor rate
Tablessalesinventorylabor
Interviewer

Your question is Store Performance 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.