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: Sales and Cost by Store
00:00
5 left

SQL: Sales and Cost by Store

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate weekly sales, labor cost, and food cost by store, and flag stores whose labor percentage exceeds a threshold at SSP Group.

Use the week from 2025-01-06 through 2025-01-12 and a labor threshold of 30%.

Output

  1. One row per SSP Group store, including stores with no activity.
  2. Return store_id, store_name, week_start, weekly_sales, weekly_labor_cost, weekly_food_cost, labor_percentage, and labor_over_threshold.
  3. Order by store_id ascending.

Schema

stores
ColumnTypeDescription
store_idPKINTUnique SSP Group store identifier
store_nameVARCHAR(100)SSP Group store name
store_daily_financials
ColumnTypeDescription
financial_idPKINTUnique daily financial record identifier
store_idINTStore associated with the daily financial record
business_dateDATETrading date for the financial record
sales_amountNUMERIC(12,2)Daily sales amount
labor_costNUMERIC(12,2)Daily labor cost
food_costNUMERIC(12,2)Daily food cost
Tablesstoresstore_daily_financials
Interviewer

Your question is SQL: Sales and Cost by Store. Start with the requirements and the two 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.