Query editor
WITH user_cohorts AS (SELECT "from" as address,date_format(min(date_trunc('month', block_date)), '%Y-%m') as cohort_month_text,min(date_trunc('month', block_date)) as cohort_month_dateFROM scroll.transactionsWHERE success = trueGROUP BY 1),following_months AS (SELECT tx."from" as address,lpad(cast(date_diff('month', uc.cohort_month_date, date_trunc('month', tx.block_date)) as varchar), 2, '0') as month_numberFROM scroll.transactions txLEFT JOIN user_cohorts uc ON tx."from" = uc.addressWHERE tx.success = trueGROUP BY 1, 2),cohort_size AS (SELECT uc.cohort_month_text as cohort_month,count(*) as new_usersFROM user_cohorts ucGROUP BY 1),retention_table AS (SELECT c.cohort_month_text as cohort_month,fm.month_number,count(*) as retained_usersFROM following_months fmLEFT JOIN user_cohorts c ON fm.address = c.addressGROUP BY 1, 2)SELECT r.cohort_month,s.new_users,r.month_number,cast(r.retained_users as double) / cast(s.new_users as double) as retention_rateFROM retention_table rLEFT JOIN cohort_size s ON r.cohort_month = s.cohort_monthWHERE r.month_number != '00'ORDER BY r.cohort_month, r.month_number