Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.