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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Store Performance SQL Analysis
00:00
5 left

Store Performance SQL Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze store-level performance by joining sales, labor, and inventory tables and identifying locations with the highest food waste. Aggregate all available records by location and preserve locations that appear in only one source.

Output

  1. One row per location with store_code, total_sales, total_units_sold, total_labor_hours, total_labor_cost, inventory_received_units, food_waste_units, food_waste_pct, and waste_rank.
  2. Include all locations, treating missing numeric measures as zero where appropriate.
  3. Rank locations by food-waste percentage descending, then waste units descending, with tied locations sharing a rank. Sort by rank and store_code.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sales record identifier
store_codeVARCHAR(10)Avi location code
sale_dateDATEDate of the sales record
sales_amountNUMERIC(12,2)Sales revenue for the record
units_soldINTFood units sold
labor
ColumnTypeDescription
labor_idPKINTUnique labor record identifier
store_codeVARCHAR(10)Avi location code
work_dateDATEDate of the labor record
labor_hoursNUMERIC(8,2)Hours worked
labor_costNUMERIC(12,2)Cost of labor
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory record identifier
store_codeVARCHAR(10)Avi location code
inventory_dateDATEDate of the inventory record
received_unitsINTFood units received
waste_unitsINTFood units discarded
Tablessaleslaborinventory
Interviewer

Your question is Store Performance SQL 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.