Amazon Customer Analytics groups buyers into monthly acquisition cohorts to monitor long-term retention. Write a SQL query to track customer cohorts defined by the calendar month of their very first purchase (`cohort_month` in 'YYYY-MM' format). For each cohort, report: 1. `cohort_month`: Calendar month of the cohort's first purchase. 2. `cohort_size`: Number of distinct customers in the cohort. 3. `month_1_retention_rate`: Percentage of the cohort who placed at least one order in the following month (month + 1), rounded to 2 decimals. 4. `month_2_retention_rate`: Percentage of the cohort who placed at least one order two months later (month + 2), rounded to 2 decimals. Order the results chronologically by `cohort_month` ascending.
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.