Brightlane's fulfillment team is clearing the backlog at the start of a new shift and needs a list of what is waiting to be processed.
Write a query to return the ID and order total of every order currently in pending status.
Assumptions:
- The
orderstable contains every order Brightlane has processed. - The
statuscolumn records the order's current stage; pending orders havestatusset to'pending'. - The
total_amountcolumn records the dollar value of each order.
Output:
- One row per pending order, with columns
idandtotal_amount.
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,
total_amount
FROM
orders
WHERE
status = 'pending' The shape
A single string-equality check on status scopes the report to one stage of the fulfillment workflow. Every order whose status isn't exactly 'pending' drops out before the result is shaped.
Clause by clause
SELECT id, total_amountreturns the two columns the fulfillment team needs to plan the shift: which order to pick and how much it's worth. Order matches the prompt's required output.FROM ordersis the source — every order Brightlane has processed, in every stage from new through delivered and cancelled.WHERE status = 'pending'keeps only rows whosestatuscolumn matches the literal'pending'exactly. The single quotes are required because the value is a string;pendingwithout quotes would be read as a column name and raise an error.
Why equality and not a range
Status columns hold a small, fixed set of values — pending, shipped, delivered, cancelled. The values aren't ordered in any meaningful way, so range operators like > or < have no business being applied to them. The only sensible comparison is equality (or its inverse). When a query needs more than one status, the right shape is to combine equality checks together rather than to reach for a range. The pattern that combines them comes later; for now, a single status filter is exactly the shape this report needs.
You practiced filtering on an enum-like status column. WHERE status = 'pending' is the recurring shape for every report scoped to a particular stage of a workflow.