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, event_id, event_name, event_time, and event_sequence.
Result columns · in this order
user_idevent_idevent_nameevent_timeevent_sequenceHow to approach it
Use ROW_NUMBER over user-level event history.
Sample input
| event_id | user_id | event_name | event_time |
|---|---|---|---|
| 1 | 1 | view | 2026-01-01 03:30:00 |
| 2 | 1 | checkout | 2026-01-01 04:10:00 |
| 6 | 1 | refund | 2026-01-03 18:00:00 |
| 3 | 2 | view | 2026-01-01 22:15:00 |
| 4 | 2 | checkout | 2026-01-02 00:30:00 |
| 5 | 3 | view | 2026-01-02 05:00:00 |
6 rows — all rows shown.
Expected output
| user_id | event_id | event_name | event_time | event_sequence |
|---|---|---|---|---|
| 1 | 1 | view | 2026-01-01 03:30:00 | 1 |
| 1 | 2 | checkout | 2026-01-01 04:10:00 | 2 |
| 1 | 6 | refund | 2026-01-03 18:00:00 | 3 |
| 2 | 3 | view | 2026-01-01 22:15:00 | 1 |
| 2 | 4 | checkout | 2026-01-02 00:30:00 | 2 |
| 3 | 5 | view | 2026-01-02 05:00:00 | 1 |
6 rows — all rows shown.
Constraints
Partition by user_id and order by event_time, ingested_at, event_id.
Expected skills
Deterministic event ordering with window functions.
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.