Practice Free
MediumJoins

Missing Inbound Supplier Shipments with LEFT JOIN

Frequently Asked By:AmazonShopifyUber
Interactive In-Browser Workspace

Practice this problem on live schema tables in PostgreSQL 16 WASM with instant row verification and visual EXPLAIN plans.

Solve in Workbench

Problem Statement

Join `supplier_pos` with `warehouse_receipts` using a `LEFT JOIN` to identify purchase orders that have never been received. Return: 1. `po.po_number` 2. `po.vendor_name` 3. `po.total_order_cost` 4. `po.expected_delivery_date` Filter to only retain purchase orders where `r.receipt_id IS NULL`. Order results by `po.expected_delivery_date` ascending.

Why Technical Interviewers Ask This

Warehouse inventory control issues purchase orders (POs) to product vendors. The inventory manager needs to identify open purchase orders that have zero receiving records logged at the fulfillment dock.

Common Pitfalls & Interview Traps

Forgetting required sorting and deterministic tie-breaking.
Not accounting for NULL or zero-value denominators during calculations.
Using inefficient quadratic subqueries instead of single-pass joins constructs.

Canonical Modern SQL Solution

PostgreSQL 16 / ANSI SQL
SELECT 
        po.po_number,
        po.vendor_name,
        po.total_order_cost,
        po.expected_delivery_date
      FROM supplier_pos po
      LEFT JOIN warehouse_receipts r ON po.po_number = r.po_number
      WHERE r.receipt_id IS NULL
      ORDER BY po.expected_delivery_date ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Joins. It meets the target criteria: List of unreceived purchase orders sorted chronologically by expected delivery date.

Edge Cases to Verbally Clarify with Your Interviewer

The dataset contains zero matching records (must return valid empty result without crashing).
Multiple records tie on sorting criteria (must evaluate tie-breaking order deterministically).
Foreign keys or secondary attributes have NULL values.

Frequently Asked Follow-Up Questions

What makes this question a favorite among Amazon and Shopify interviewers?

Interviewers use this problem to test whether candidates write defensive, scalable Joins queries that run efficiently on multi-million row production databases without excessive memory usage.

How does the query optimizer execute this query?

Using single-pass table scans with index lookups or sort buffers. Running EXPLAIN (ANALYZE, BUFFERS) in the DB Exercises workbench visualizes the execution nodes and buffer hit cache.

More FAANG SQL Interview Questions

View all questions