Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Return order_id, buyer_id, status, and total_amount for paid orders only, newest first by created_at, limited to the 5 most recent.
Result columns · in this order
order_id | Order identifier; unique in this table. |
buyer_id | customer_id of the buyer. |
status | Order status: paid, shipped, pending, or refunded. |
total_amount | Order total in dollars. |
How to approach it
Start from orders, filter to status = 'paid', then order by created_at DESC and LIMIT 5.
Sample input
| order_id | buyer_id | status | total_amount | created_at |
|---|---|---|---|---|
| 1011 | 2 | paid | 110 | 2026-02-02 09:00:00 |
| 1010 | 6 | paid | 640 | 2026-01-30 21:10:00 |
| 1007 | 3 | paid | 95 | 2026-01-22 14:46:00 |
| 1005 | 2 | paid | 540 | 2026-01-18 09:05:00 |
| 1002 | 3 | paid | 120 | 2026-01-12 10:02:00 |
| 1001 | 1 | paid | 80 | 2026-01-12 08:40:00 |
| 1003 | 4 | pending | 40 | 2026-01-13 11:15:00 |
7 rows — all rows shown.
Expected output
| order_id | buyer_id | status | total_amount |
|---|---|---|---|
| 1011 | 2 | paid | 110 |
| 1010 | 6 | paid | 640 |
| 1007 | 3 | paid | 95 |
| 1005 | 2 | paid | 540 |
| 1002 | 3 | paid | 120 |
5 rows — all rows shown.
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.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.