Practice Free
EasyFundamentals

Express Fulfillment Order Queue

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

Filter the `fulfillment_queue` table for orders where: - `shipping_tier` is `'Express'` - `fulfillment_status` is **not** `'shipped'` - `total_price` is greater than or equal to **$250.00** Return: 1. `order_id` 2. `customer_email` 3. `total_price` 4. `fulfillment_status` Order the result by `total_price` descending. For ties, sort by `order_id` ascending.

Why Technical Interviewers Ask This

A luxury fashion e-commerce warehouse has a customer SLA guaranteeing same-day dispatch for express orders over $250. The fulfillment operations lead needs an active queue of orders marked for express delivery that haven't shipped yet.

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 fundamentals constructs.

Canonical Modern SQL Solution

PostgreSQL 16 / ANSI SQL
SELECT 
        order_id,
        customer_email,
        total_price,
        fulfillment_status
      FROM fulfillment_queue
      WHERE shipping_tier = 'Express'
        AND fulfillment_status != 'shipped'
        AND total_price >= 250.00
      ORDER BY total_price DESC, order_id ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Fundamentals. It meets the target criteria: Express delivery orders >= $250 still pending or processing, sorted by price descending.

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 Fundamentals 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