Brightlane's logistics dashboard displays the active order queue for the dispatch team. It should show every order that is either awaiting dispatch (status = 'pending') or currently in transit (status = 'shipped').
Write a query to return the ID and status of each such order.
Assumptions:
- The
orderstable contains every order Brightlane has processed. - Only the two listed statuses qualify; all other status values should be excluded.
Output:
- One row per qualifying order, with columns
idandstatus.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
id,
status
FROM
orders
WHERE
status IN ('pending', 'shipped') The shape
IN ('pending', 'shipped') is the compact form of a membership test against a small set of values — the active queue is defined by two statuses, and the parentheses hold both.
Clause by clause
SELECT id, statusreturns the two columns the dispatch dashboard needs: the order identifier and which of the two active statuses it sits in. Pullingstatusalongsideidlets the team see at a glance whether each row ispendingor alreadyshipped.FROM ordersreads the order table.WHERE status IN ('pending', 'shipped')keeps only the rows whosestatusmatches one of the two values in the parentheses. Every other status —delivered,cancelled, anything else — is dropped.
You practiced using IN to test membership against a list of values. status IN ('pending', 'shipped') reads identically to status = 'pending' OR status = 'shipped' — the recurring shape any time you'd otherwise be chaining equality checks with OR.