Skip to main content
All Problems
hard0% acceptance

Inventory Reorder Alert with Sales Velocity

Create an inventory alert system. Compute each product's average daily sales quantity over the last 30 days (from '2025-01-01'). Then estimate days until stockout as stock_quantity / avg_daily_sales. Flag products where days_until_stockout < 14 as 'REORDER'. Show product name, stock_quantity, avg_daily_sales (rounded to 2), days_until_stockout (rounded to 0), and the flag. Sort by days_until_stockout.

Schema

🔑idINT
nameTEXT
🔗category_idINT
priceREAL
costREAL
stock_quantityINT
created_atTIMESTAMP
postgresql

Run your query to see results

Press Ctrl + Enter to execute