SQL · Level 1 Filtering

SQL WHERE and NULL

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

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;

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.

Sample data from the first test. The other tests use different rows, so write a query, not a list of answers.

orders 6 rows
idINTEGERcustomerTEXTtotalREALshipped_atTEXT
1Ana42.52024-03-01
2Bo35.0NULL
3Cy12.0NULL
4Di80.0NULL
5Eve20.0NULL
6Finn64.02024-03-02
solution.sql
Test Suites Pending
Output