Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Low-Stock Items via SQL Join

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Low-Stock Items via SQL Join. Start with the requirements and the two tables on the right.

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.

Problem

Write a SQL query to join our inventory and sales tables to identify low-stock items.

Use current_stock and reorder_level to identify products at or below their reorder level. Summarize sales from January 2025, including products with no qualifying sales.

Output

  1. One row per qualifying product with product_id, product_name, current_stock, reorder_level, and total_units_sold
  2. Include only products with a non-null reorder level and stock at or below that level
  3. Order by current_stock ascending, then product_id ascending

Schema

inventory
ColumnTypeDescription
product_idPKINTUnique product identifier
product_nameVARCHAR(100)Product name
current_stockINTUnits currently available
reorder_levelINTStock level that triggers replenishment
sales
ColumnTypeDescription
sale_idPKINTUnique sale identifier
product_idINTProduct sold
sale_dateDATEDate of sale
quantityINTNumber of units sold
Tablesinventorysales
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results