Given a table of user web sessions, write a query to identify the drop-off rate at each stage of the checkout funnel for Wayfair.
Use all sessions in the table. Treat a session as reaching a stage when its corresponding flag is true. Calculate each stage's drop-off rate relative to the immediately preceding stage.
stage_name, sessions_reaching_stage, drop_off_rateNULL for the first stage's drop-off rate| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique identifier for a web session |
| user_id | INT | Wayfair customer identifier when available |
| source_channel | VARCHAR(30) | Marketing or traffic source for the session |
| viewed_product | BOOLEAN | Whether the session viewed a product |
| added_to_cart | BOOLEAN | Whether the session added an item to cart |
| started_checkout | BOOLEAN | Whether the session started checkout |
| entered_payment | BOOLEAN | Whether the session reached payment |
| completed_order | BOOLEAN | Whether the session completed an order |