SQL · Intermediate · 35 min
A checkout funnel in the right order
Count users who actually progressed through the stages.
Task
Compute a view → add_to_cart → purchase funnel from events. Each stage must occur strictly after the preceding stage for the same visitor. Repeated events should not inflate user counts.
Requirements
- events has visitor_id, kind, and at_seconds. Kinds are view, add_to_cart, or purchase.
- Count users once per stage. A cart without an earlier view does not qualify; a purchase before the qualifying cart does not qualify.
- Return exactly one row with viewed, added, and purchased, including zeros on empty input.
- There is no session boundary in this exercise. All supplied events belong to the analysis period.
Funnel analysisOrdered eventsConditional aggregation
Loading exercise…