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

SQL for Declining Inventory Turnover

HardSQL · PostgreSQL

Problem

Write a SQL query to identify stores with declining inventory turnover over the last 3 months, including month-over-month change and rank by decline severity.

Use the provided store, inventory, and sales data. Include only stores with valid turnover values for all three months and decreases in both month-over-month comparisons.

Output

  1. One row per qualifying store.
  2. Columns: store_id, store_name, first_month_turnover, latest_month_turnover, first_mom_change, second_mom_change, latest_mom_change, total_decline, and decline_rank.
  3. Rank stores by total_decline descending, with lower store_id breaking ties.

Schema

stores
ColumnTypeDescription
store_idPKINTEGERUnique store identifier
store_nameVARCHAR(100)Store display name
cityVARCHAR(80)Store city
regionVARCHAR(40)Operating region
monthly_inventory
ColumnTypeDescription
inventory_idPKINTEGERUnique monthly inventory record
store_idINTEGERReferenced store identifier
month_startDATEFirst day of the inventory month
average_inventory_unitsNUMERIC(12,2)Average inventory units held during the month
monthly_sales
ColumnTypeDescription
sales_idPKINTEGERUnique monthly sales record
store_idINTEGERReferenced store identifier
month_startDATEFirst day of the sales month
units_soldINTEGERUnits sold during the month
Tablesstoresmonthly_inventorymonthly_sales
Interviewer

Your question is SQL for Declining 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.