← All SQL interview questions
Shipments still missing a delivery timestamp
EasyNULL / NOT NULL HandlingOlaEXL
A logistics control tower flags every dispatch that has left the warehouse but has no delivery confirmation yet. Undelivered parcels have a NULL value in delivered_at.
Return dispatch_id, order_ref and courier_partner for all dispatches that are not yet delivered.
Sample data
Table: courier_dispatch
12 row(s) · showing first 8
| dispatch_idINT | order_refTEXT | courier_partnerTEXT | dispatched_atTIMESTAMP | delivered_atTIMESTAMP |
|---|---|---|---|---|
| 301 | ORD-4411 | BlueDart | 2026-02-01 | 2026-02-03 |
| 302 | ORD-4412 | Delhivery | 2026-02-01 | NULL |
| 303 | ORD-4413 | Ecom Express | 2026-02-02 | 2026-02-05 |
| 304 | ORD-4414 | BlueDart | 2026-02-02 | NULL |
| 305 | ORD-4415 | Shadowfax | 2026-02-03 | 2026-02-04 |
| 306 | ORD-4416 | Delhivery | 2026-02-03 | NULL |
| 307 | ORD-4417 | XpressBees | 2026-02-04 | 2026-02-07 |
| 308 | ORD-4418 | Shadowfax | 2026-02-05 | NULL |
courier_dispatch
- dispatch_idINT
- order_refTEXT
- courier_partnerTEXT
- dispatched_atTIMESTAMP
- delivered_atTIMESTAMP
- Step 1: Identify the column that encodes the missing event — `delivered_at` is `NULL` until the parcel is signed for.
- Step 2: Filter with `delivered_at IS NULL`. This is the only correct test for missing values.
- Step 3: Do **not** write `delivered_at = NULL`. In SQL any comparison with `NULL` evaluates to unknown, so that predicate would return zero rows.
- Step 4: Project the three requested columns and you are done — no aggregation or joins needed.
SELECT dispatch_id, order_ref, courier_partner
FROM courier_dispatch
WHERE delivered_at IS NULL;Learn the concept first
Stuck on NULL / NOT NULL Handling? These free SQL lessons teach it step by step.
More NULL / NOT NULL Handling questions
Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.
Explore the program