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

SQL for Store Performance Insights

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze weekly store performance by region, joining sales, inventory, and labor tables to identify stores with declining sales and low in-stock rates at L.L. Bean.

Treat declining sales as a current weekly total below the prior week and low in-stock as a rate below 90%. Include only weeks with a prior sales week.

Output

  1. One row per store and week meeting both conditions
  2. Columns: region, store_id, week_start, weekly_sales, prior_week_sales, sales_decline_pct, in_stock_rate, and labor_hours
  3. Sort by region, store_id, and week_start ascending

Schema

weekly_sales
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
store_idVARCHAR(10)L.L. Bean store identifier
regionVARCHAR(50)Store operating region
week_startDATEStart date of the sales week
net_salesDECIMAL(12,2)Net sales amount for the transaction
inventory
ColumnTypeDescription
store_idVARCHAR(10)L.L. Bean store identifier
regionVARCHAR(50)Store operating region
week_startDATEStart date of the inventory week
units_in_stockINTUnits available during the week
units_expectedINTUnits expected to be available during the week
labor
ColumnTypeDescription
labor_idPKINTUnique labor record identifier
store_idVARCHAR(10)L.L. Bean store identifier
regionVARCHAR(50)Store operating region
week_startDATEStart date of the labor week
labor_hoursDECIMAL(8,2)Labor hours recorded for the week
Tablesweekly_salesinventorylabor
Interviewer

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