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 buyer_id, first_order_at, and latest_order_at.
Result columns · in this order
buyer_idfirst_order_atlatest_order_atHow to approach it
Group by buyer_id and compare MIN/MAX timestamps.
Sample input
| order_id | buyer_id | created_at |
|---|---|---|
| 1001 | 1 | 2026-01-12 08:40:00 |
| 1004 | 1 | 2026-01-15 14:20:00 |
| 1009 | 1 | 2026-01-28 18:00:00 |
| 1002 | 3 | 2026-01-12 10:02:00 |
| 1012 | 3 | 2026-02-05 10:00:00 |
5 rows — all rows shown.
Expected output
| buyer_id | first_order_at | latest_order_at |
|---|---|---|
| 1 | 2026-01-12 08:40:00 | 2026-01-28 18:00:00 |
| 2 | 2026-01-18 09:05:00 | 2026-02-02 09:00:00 |
| 3 | 2026-01-12 10:02:00 | 2026-02-05 10:00:00 |
| 4 | 2026-01-13 11:15:00 | 2026-01-25 12:00:00 |
| 6 | 2026-01-20 16:45:00 | 2026-01-30 21:10:00 |
5 rows — all rows shown.
Constraints
Use MIN and MAX over created_at grouped by buyer_id. Order by buyer_id.
Expected skills
First/last entity summaries and grouped timestamp logic.
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.