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 user_id, first_view_at, and first_checkout_at.
Result columns · in this order
user_idfirst_view_atfirst_checkout_atHow to approach it
Build first_view and first_checkout CTEs, then compare timestamps.
Sample input
| user_id | event_name | event_time |
|---|---|---|
| 1 | view | 2026-01-01 03:30:00 |
| 1 | checkout | 2026-01-01 04:10:00 |
| 2 | view | 2026-01-01 22:15:00 |
| 2 | checkout | 2026-01-02 00:30:00 |
4 rows — all rows shown.
Expected output
| user_id | first_view_at | first_checkout_at |
|---|---|---|
| 1 | 2026-01-01 03:30:00 | 2026-01-01 04:10:00 |
| 2 | 2026-01-01 22:15:00 | 2026-01-02 00:30:00 |
2 rows — all rows shown.
Constraints
Use event_time for behavior ordering, compute first view and first checkout separately, then keep checkout after view. Order by user_id.
Expected skills
Event-time sequence reasoning and funnel construction.
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.