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 Weekly Inventory Turnover
00:00
5 left

SQL for Weekly Inventory Turnover

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate weekly inventory turnover by store at Walmart and rank stores by turnover within each region.

Use the provided store, inventory snapshot, and sales transaction data for the week beginning January 6, 2025. Include active stores with inventory records for the week, including stores with no qualifying sales.

Output

  1. One row per active store and week
  2. Columns: week_start, region, store_id, store_name, cogs, avg_inventory_value, turnover, and regional_rank
  3. Turnover is cost of goods sold divided by average inventory value
  4. Sort by region, regional_rank, then store_id

Schema

stores
ColumnTypeDescription
store_idPKINTUnique Walmart store identifier
store_nameVARCHAR(100)Store display name
regionVARCHAR(50)Operational region containing the store
is_activeBOOLEANWhether the store is currently active
inventory_snapshots
ColumnTypeDescription
snapshot_idPKINTUnique inventory snapshot identifier
store_idINTStore associated with the snapshot
snapshot_dateDATEDate of the inventory measurement
inventory_valueNUMERIC(14,2)Inventory value at the snapshot date
sales_transactions
ColumnTypeDescription
transaction_idPKINTUnique sales transaction identifier
store_idINTStore where the sale occurred
sale_dateDATEDate of the sale
quantityINTUnits sold
unit_costNUMERIC(10,2)Cost per unit sold
Tablesstoresinventory_snapshotssales_transactions
Interviewer

Your question is SQL for Weekly Inventory Turnover. 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.