Query editor
with setUsers as (select distinct user,date_trunc('month',evt_block_time) as tx_date from query_1868543UNION ALLselect address,date_trunc('month',date) from query_2117280),base as (SELECTdistincttx_date as month,userFROM setUsersWHERE tx_date >= now() - interval '12' month), user_cohort as (--get the cohort start month for a specific user addressSELECTmin(month) as cohort, userFROM basegroup by 2), cohort_size as (SELECTcohort, count(*) as total_sizeFROM user_cohortgroup by 1), active_by_cohort as (SELECTcohort, month, row_number() OVER (partition by cohort order by month asc) as months, active_addressesFROM (SELECTu.cohort, b.month, count(*) as active_addressesFROM base bLEFT JOIN user_cohort u ON u.user = b.usergroup by 1,2)), retention_base as (SELECTa.cohort, total_size, map_agg(months, cast(active_addresses as double)/cast(total_size as double)) as retention_keyFROM active_by_cohort aLEFT JOIN cohort_size c ON c.cohort = a.cohortGROUP BY 1,2)SELECT