The checkout funnel is app_open -> menu_view -> add_to_cart -> order_placed. A user reaches a step only if they performed that event at or after the moment they reached the previous step (use the earliest qualifying event each time). Events done before the earlier step do not count. For every city in `app_users` (even if nobody opened the app) return `city`, `opened`, `viewed_menu`, `added_cart`, `ordered` (distinct users reaching each step) and `conversion_pct` = ROUND(100.0 * ordered / opened, 1) (NULL when opened = 0). Order by `city`.
| Column | Type |
|---|---|
| user_id | INTEGER |
| city | TEXT |
| user_id | city |
|---|---|
| 1 | Bengaluru |
| 2 | Bengaluru |
| 3 | Bengaluru |
| 4 | Pune |
| 5 | Pune |
| Column | Type |
|---|---|
| user_id | INTEGER |
| event_name | TEXT |
| event_ts | TIMESTAMP |
| user_id | event_name | event_ts |
|---|---|---|
| 1 | app_open | 2026-08-01 10:00:00 |
| 1 | menu_view | 2026-08-01 10:01:00 |
| 1 | add_to_cart | 2026-08-01 10:05:00 |
| 1 | order_placed | 2026-08-01 10:07:00 |
| 2 | app_open | 2026-08-01 11:00:00 |
| 2 | menu_view | 2026-08-01 11:02:00 |
| 3 | menu_view | 2026-08-01 09:00:00 |
| 4 | app_open | 2026-08-01 12:00:00 |
| city | opened | viewed_menu | added_cart | ordered | conversion_pct |
|---|---|---|---|---|---|
| Bengaluru | 2 | 2 | 1 | 1 | 50 |
| Pune | 2 | 1 | 1 | 1 | 50 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Median Order Value per Category (No MEDIAN) · Delivery SLA by Meal Band ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.