The clerk dashboard shows a short recent-orders strip. Return order_id, customer_id, and placed_on for the two newest orders. Break ties with the larger order_id first so the page is stable.
Requirements
Keep the supplied orders table unchanged.
Return exactly order_id, customer_id, and placed_on.
Sort placed_on descending, then order_id descending.
Return at most two rows with LIMIT 2.
Do not filter by customer.
Do not use OFFSET.
Example
Input
Keep the orders table, then select the two newest rows.
Newest first is ORDER BY placed_on DESC. LIMIT 2 then keeps a page, not a dump. August 20 is older than September, so Alonzo's order 4 drops off. Ada's September 19 beats Grace's September 10. A second sort on order_id DESC makes two orders on the same calendar day deterministic; without it the engine may swap them. OFFSET is the next page of a broken pagination style; this exercise only asks for the first two rows. Dates are ISO text so lexicographic order matches chronology. Keyset pagination would use WHERE placed_on < last_seen for later pages; LIMIT without a stable ORDER BY is how dashboards flicker.
Why this pattern matters
A dashboard strip is a page: sort, then LIMIT. Without a key tie-breaker, two orders on the same day swap between refreshes and clerks double-handle work.
Solution walkthrough
Sort placed_on descending so 2026-09-19 is first.
Add order_id descending.
LIMIT 2 drops August and Ada's first September order.
Common mistakes to avoid
LIMIT without ORDER BY.
ASC dates showing the oldest page.
OFFSET 0 as cargo-cult pagination.
What this exercise teaches
Sort descending by a date column
Cap a result with LIMIT
Add a tie-breaker on the primary key
A PRACTICAL PLAN
Work through Page the two most recent orders with intent.
Translate the contract.Turn the requirements into a short checklist before editing your-solution.sql.
Use the example as evidence.Predict the result for the supplied input, then add one boundary case such as an empty value, a limit, or unexpected input.
Review the implementation.Compare your choices against solution.sql only after a real attempt.
EXERCISE FAQ
Before you move on.
What does “Page the two most recent orders” teach?
This beginner SQL exercise focuses on Sort descending by a date column, Cap a result with LIMIT, Add a tie-breaker on the primary key. Its requirements define the exact behavior to implement before you write code.
How should I validate this SQL solution?
Start with the displayed example input and expected output, then test a boundary case suggested by the requirements. Open your-solution.sql and select Run code. The browser creates a fresh isolated SQLite database, executes the complete script, and compares its result rows with the expected report.
When should I open the reference solution?
Attempt Page the two most recent orders first. Then open the read-only solution file to compare the contract, edge-case handling, and implementation choices—not simply to copy the final code.