Practice Free
← Syllabus|
Easy

14. Critical Warehouse Low Stock & Reorder Thresholds

EasyFundamentalsPostgreSQL 16PRO
Table: product_inventory
+--------------------+--------------+
| Column Name        | Type         |
+--------------------+--------------+
| sku                | varchar(20)  |
| product_name       | varchar(100) |
| available_units    | int          |
| supplier_lead_days | int          |
+--------------------+--------------+

sku is the unique key for this table. Each row contains record details for this enterprise dataset.

Supply chain replenishment systems monitor on-hand inventory levels against reorder safety thresholds to prevent stockout outages during peak sales cycles.

Write a query to find all inventory records in `product_inventory` where available stock is critically depleted: - `available_units < 20` - `supplier_lead_days > 3` Return: 1. `sku` 2. `product_name` 3. `available_units` 4. `supplier_lead_days` Order results by `available_units` ascending, then by `sku` ascending.

Return the result table ordered as specified. The result format is in the following example.

Example 1:
Input:
Preparing sample rows...
Output:
Calculating benchmark target...
Explanation:

Low stock items requiring immediate vendor replenishment.

Constraints:
  • Query must utilize clause(s): WHEREORDER BY
  • Result order matters (tie-breakers and sort order must be strictly preserved).
  • Engine: PostgreSQL 16 standard syntax (in-browser WASM).
query.sql|PostgreSQL 16 WASM
Loading SQL editor...
You must run your code first

Write your SQL query in the editor and click Run or Submit to test against in-browser PostgreSQL 16 WASM.

About the “Critical Warehouse Low Stock & Reorder Thresholds” SQL Problem

Business Scenario

Supply chain replenishment systems monitor on-hand inventory levels against reorder safety thresholds to prevent stockout outages during peak sales cycles.

Expected Output & Criteria

Low stock items requiring immediate vendor replenishment.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM
CREATE TABLE product_inventory (
        sku VARCHAR(20) PRIMARY KEY,
        product_name VARCHAR(100) NOT NULL,
        available_units INT NOT NULL,
        supplier_lead_days INT NOT NULL
      );

Target SQL Clauses & Operators

WHEREORDER BY

Want more Fundamentals practice?

Explore the full syllabus of 16 exercises and syntax guides.

View Fundamentals Track