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 Join
00:00
5 left

Store Performance SQL Join

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze LEGO Group store performance by joining sales, inventory, and staffing tables to identify locations with low stock and declining revenue. Use the latest sales month for the comparison. Treat a location as low stock when total stock is below its total reorder level, and include the latest available staffing data for each location.

Output

  1. One row per qualifying LEGO Group store.
  2. Columns: store_id, current_revenue, prior_revenue, revenue_change_pct, stock_units, reorder_level, employee_count, and scheduled_hours.
  3. Include only stores with lower latest-month revenue and low stock. Order by revenue_change_pct ascending, then store_id.

Schema

sales
ColumnTypeDescription
sale_idPKINTEGERUnique sales record identifier
store_idVARCHAR(20)LEGO Group store identifier
sale_monthDATEFirst day of the sales month
revenueNUMERIC(12,2)Revenue recorded by the sales row
inventory
ColumnTypeDescription
inventory_idPKINTEGERUnique inventory record identifier
store_idVARCHAR(20)LEGO Group store identifier
skuVARCHAR(30)LEGO product SKU
stock_unitsINTEGERUnits currently in stock
reorder_levelINTEGERMinimum desired units before replenishment
staffing
ColumnTypeDescription
staffing_idPKINTEGERUnique staffing record identifier
store_idVARCHAR(20)LEGO Group store identifier
staff_monthDATEMonth covered by the staffing record
employee_countINTEGERNumber of employees assigned to the store
scheduled_hoursNUMERIC(10,2)Scheduled staff hours for the month
Tablessalesinventorystaffing
Interviewer

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