Chapter 9 · Interview Level
54. Account Cohort Activity Analysis
Hard40 XPFinance
Perform a cohort analysis on accounts. The cohort is defined by the month the account was opened (cohort_month). For each cohort, count how many accounts had at least one transaction in the same month they were opened (active_in_month_0) versus the total accounts in that cohort (cohort_size). Return cohort_month, cohort_size, active_in_month_0, and activation_rate (rounded to 2 decimals, as a percentage). Order by cohort_month.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- account_typeTEXT
- balanceREAL
- currencyTEXT
- opened_atTEXT
- statusTEXT
- PKidINT
- FKaccount_id→ accounts.idINT
- transaction_dateTEXT
- typeTEXT
- amountREAL
- balance_afterREAL
- descriptionTEXT
- reference_numberTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.