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 Sales Down, Inventory High
00:00
5 left

SQL for Sales Down, Inventory High

MediumSQL · PostgreSQL

Problem

Write a SQL query to combine daily sales, inventory, and staffing tables to identify Victoria's Secret stores where sales are down but inventory is high.

Use the latest date represented in the daily sales data. Sales are down when total sales are lower than the store's previous day, and inventory is high when it is at least the average inventory across stores on that date.

Output

  1. One row per qualifying store with store_id, current sales, previous-day sales, decline percentage, inventory units, average inventory units, and staff count
  2. Include only stores meeting both conditions, ordered by greatest decline percentage, then store_id

Schema

daily_sales
ColumnTypeDescription
sales_idPKINTUnique sales record identifier
store_idINTVictoria's Secret store identifier
sale_dateDATEDate of the sales record
net_salesDECIMAL(12,2)Net sales amount for the record
daily_inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
store_idINTVictoria's Secret store identifier
inventory_dateDATEDate of the inventory snapshot
inventory_unitsINTUnits available in store inventory
daily_staffing
ColumnTypeDescription
staffing_idPKINTUnique staffing record identifier
store_idINTVictoria's Secret store identifier
staff_dateDATEDate of the staffing record
staff_countINTNumber of scheduled staff
Tablesdaily_salesdaily_inventorydaily_staffing
Interviewer

Your question is SQL for Sales Down, Inventory High. 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.