CODE WORKSPACE

Interview event funnel sequence

Return users whose first checkout happened after their first view.

Start by naming the output grain, then build CTEs that can be inspected one at a time.

Sample input

eventsA user qualifies only when first checkout is after first view.
user_idevent_nameevent_time
1view2026-01-01 03:30:00
1checkout2026-01-01 04:10:00
2view2026-01-01 22:15:00
2checkout2026-01-02 00:30:00

Expected output

Expected outputBoth users qualify because checkout happened after view.
user_idfirst_view_atfirst_checkout_at
12026-01-01 03:30:002026-01-01 04:10:00
22026-01-01 22:15:002026-01-02 00:30:00

Constraints

State the output contract first, use readable CTE layers, return the exact columns requested by the prompt, and use deterministic ordering.

Expected skills

Interview clarification, SQL structure, edge-case handling, and final-answer narration.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.