Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Store Performance Analysis
00:00
5 left

SQL Store Performance Analysis

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze store performance by joining sales, labor, and inventory tables and summarizing key operational metrics by store and week for Walgreens.

Return all store-week combinations found in any source table. Use the available data to calculate the requested metrics and handle missing source records appropriately.

Output

  1. One row per store and week, ordered by store_id, then week_start.
  2. Columns: store_id, week_start, sales_units, sales_revenue, labor_hours, labor_cost, avg_inventory_units, stockout_days, and revenue_per_labor_hour.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sales record identifier
store_idINTWalgreens store identifier
week_startDATEStart date of the reporting week
units_soldINTUnits sold, including negative return quantities
sales_amountDECIMAL(12,2)Sales revenue for the record
labor
ColumnTypeDescription
labor_idPKINTUnique labor record identifier
store_idINTWalgreens store identifier
week_startDATEStart date of the reporting week
hours_workedDECIMAL(8,2)Employee hours worked
labor_costDECIMAL(12,2)Labor cost for the record
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory observation identifier
store_idINTWalgreens store identifier
week_startDATEStart date of the reporting week
on_hand_unitsINTObserved units available in inventory
Tablessaleslaborinventory
Interviewer

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