Overview
List the orders still waiting to ship: filter rows with WHERE and AND, and find missing dates with IS NULL instead of the = NULL trap.
- SELECT columns FROM table
- WHERE with AND
- IS NULL, never = NULL
- ORDER BY
Short Course
WHERE keeps only the rows that match a condition; join conditions with
AND or OR. Trap: = NULL is never true, not even for missing values.
Test for them with IS NULL.
SELECT id, customer
FROM orders
WHERE total > 50
AND shipped_at IS NULL -- not "= NULL"
ORDER BY id;
Task
Return the id and customer of every order with no shipped_at date and a
total of at least 20, ordered by id. In the database below, Bo's order
(id 2) is one of them.
Database
Sample data from the first test. The other tests use different rows, so write a query, not a list of answers.
| idINTEGER | customerTEXT | totalREAL | shipped_atTEXT |
|---|---|---|---|
| 1 | Ana | 42.5 | 2024-03-01 |
| 2 | Bo | 35.0 | NULL |
| 3 | Cy | 12.0 | NULL |
| 4 | Di | 80.0 | NULL |
| 5 | Eve | 20.0 | NULL |
| 6 | Finn | 64.0 | 2024-03-02 |
Test Suites
Pending
Next
Output