Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.