CODE WORKSPACE

First look at the orders table

Return order_id, buyer_id, status, and total_amount for paid orders only, newest first by created_at, limited to the 5 most recent.

Start from orders, filter to status = 'paid', then order by created_at DESC and LIMIT 5.

Sample input

ordersPaid orders shown plus one pending row that is filtered out. The sandbox holds 12 orders.
order_idbuyer_idstatustotal_amountcreated_at
10112paid1102026-02-02 09:00:00
10106paid6402026-01-30 21:10:00
10073paid952026-01-22 14:46:00
10052paid5402026-01-18 09:05:00
10023paid1202026-01-12 10:02:00
10011paid802026-01-12 08:40:00
10034pending402026-01-13 11:15:00

Expected output

Expected outputThe 5 most recent paid orders by created_at. Order 1001 is the 6th and drops off.
order_idbuyer_idstatustotal_amount
10112paid110
10106paid640
10073paid95
10052paid540
10023paid120

Constraints

Select only the four named columns (no SELECT *). Keep only paid orders. Order by created_at descending and return at most 5 rows.

Expected skills

Choosing explicit columns, filtering with WHERE, ordering with ORDER BY, and sampling with LIMIT.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.