Escalate Pending Orders Safely
Change pending orders for account 1 to review.
- UPDATE
- Predicate safety
Exercise brief
Understand the request
Risk operations Only pending orders for Acme Enterprise require manual review; completed orders and other customers are unaffected.
Risk operations needs Acme Enterprise's pending orders moved into manual review.
Return
- Update only the intended order state.
Constraints
- Match both account_id and current status.
- Preserve completed and unrelated orders.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
orders
order_idINTEGERaccount_idINTEGERstatusVARCHAR(20)
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
A safe UPDATE starts by identifying the exact target rows with a predicate.
Hint 2
Combine account_id = 1 with status = 'pending' in the WHERE clause.
Hint 3
UPDATE orders SET status = 'review' WHERE account_id = 1 AND status = 'pending';
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
UPDATE orders
SET status = 'review'
WHERE account_id = 1 AND status = 'pending';Why this works
The compound predicate prevents a broad update and makes the current state part of the change contract.
Success check
Order 501 is in review while order 504 remains completed and order 502 remains pending.
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
WHERE Clause & Filtering
Practice SQL WHERE clauses with realistic boundary, NULL, text, date, exclusion, and production-filtering problems.
SQL Joins
Practice reliable INNER, LEFT, FULL, CROSS, self, semi, anti, range, temporal, and many-to-many join patterns.
Basic SQL Functions
Practice production-oriented string cleanup, numeric transformations, NULL handling, tolerant conversion, and delimiter parsing.
Open the interactive workspace and practice across SQL topics.