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 weekly store performance at T-Mobile by joining sales, inventory, and staffing tables, and return the top stores by revenue, inventory shrink, and labor efficiency. Treat weeks as Monday through Sunday. Inventory shrink is expected units minus counted units, and labor efficiency is revenue divided by labor hours.

Output

  1. One row per store-week ranked in the top three for at least one metric, with week_start, store_id, weekly_revenue, shrink_units, labor_efficiency, and the three rank columns.
  2. Include ties, order by week_start, then store_id.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sale identifier
store_idVARCHAR(10)T-Mobile store identifier
sale_dateDATEDate of sale
revenueNUMERIC(12,2)Revenue generated by the sale
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
store_idVARCHAR(10)T-Mobile store identifier
snapshot_dateDATEInventory count date
expected_unitsINTUnits expected from inventory records
counted_unitsINTUnits physically counted
staffing
ColumnTypeDescription
staffing_idPKINTUnique staffing record identifier
store_idVARCHAR(10)T-Mobile store identifier
shift_dateDATEStaffing shift date
employee_countINTNumber of employees assigned
labor_hoursNUMERIC(8,2)Hours worked
Tablessalesinventorystaffing
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.