Amazon's growth team tracks a three-step funnel: `view` -> `add_to_cart` -> `purchase`. A user counts toward a step only if they completed the previous steps first, using each user's earliest event of each type: the first `add_to_cart` must be after the first `view`, and the first `purchase` must be after the first `add_to_cart`. A user who purchased without viewing, or who added to cart before ever viewing, does not count for later steps. Write an SQL query that returns a single row with `viewed_users`, `carted_users`, `purchased_users`, `view_to_cart_pct` (carted / viewed * 100, rounded to 2 decimals) and `cart_to_purchase_pct` (purchased / carted * 100, rounded to 2 decimals).
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.