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
SQL for Store Performance Insights
00:00
5 left

SQL for Store Performance Insights

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze store performance by day, joining sales, staffing, and inventory tables to identify locations with low sales, understaffing, and stockouts. Treat low sales as daily sales below 500, understaffing as staffed hours below 80% of scheduled hours, and a stockout as any SKU with zero units on hand.

Output

  1. Return one row per Dunkin store and business date meeting all three conditions.
  2. Include store_code, business_date, daily_sales, scheduled_hours, staffed_hours, and stockout_sku_count.
  3. Order by business_date, then store_code.

Schema

stores
ColumnTypeDescription
store_idPKINTUnique Dunkin store identifier
store_codeVARCHAR(20)Operational store code
store_nameVARCHAR(100)Store display name
sales
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
store_idINTReferenced Dunkin store
sale_dateDATEBusiness date of the sale
net_salesDECIMAL(10,2)Net transaction sales amount
staffing
ColumnTypeDescription
staffing_idPKINTUnique staffing record identifier
store_idINTReferenced Dunkin store
work_dateDATEStaffing business date
scheduled_hoursDECIMAL(6,2)Scheduled labor hours
staffed_hoursDECIMAL(6,2)Actual staffed labor hours
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
store_idINTReferenced Dunkin store
inventory_dateDATEInventory snapshot date
skuVARCHAR(40)Inventory item identifier
units_on_handINTUnits available at the snapshot
Tablesstoressalesstaffinginventory
Interviewer

Your question is SQL for Store Performance Insights. Start with the requirements and the four 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.