A retention analysis asks: after each event, what did the same user do next? Each user's events form their own timeline ordered by ts; the last event of a timeline has no next event.
Write a query returning user_id, event and the following event of the same user as next_event, using LEAD().
user_id, event, next_eventnext_event NULLLEAD is the mirror image of LAG: it reads the next row.
Use PARTITION BY user_id ORDER BY ts so users do not mix.
No results yet
Run your code to check it against the examples, or submit to run every test.