Query editor
with info_created as (selectentity,pubkey,block_time as created_atfrom staking_ethereum.flowsWHERE withdrawal_address != 0xe3c44d4d25172ef2e0cdb9e09189a8ca4ed878f4and amount_staked = 32),info_exited as (selectpubkey,block_time as exited_atfrom staking_ethereum.flowsWHERE withdrawal_address != 0xe3c44d4d25172ef2e0cdb9e09189a8ca4ed878f4and amount_full_withdrawn = 32),info_earned as (selectpubkey,sum(amount_partial_withdrawn) as earnedfrom staking_ethereum.flowsWHERE withdrawal_address != 0xe3c44d4d25172ef2e0cdb9e09189a8ca4ed878f4group by 1),final as (selecti.entity,i.pubkey,date_trunc('month',i.created_at) as cohort_start,date_trunc('month',e.exited_at) as cohort_exit,i.created_at,e.exited_at,case when DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) > 365*2 then '>= 2 years'when DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) > 365 andDATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) <= 365*2 then '1-2 years'when DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) > 180 andDATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) <= 365 then '6-12 month'when DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) > 90 andDATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) <= 180 then '3-6 month'when DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) > 0 andDATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date)) <= 90 then '1-3 month'end as age,case when e.exited_at is not null then 'off' else 'live' end as status,earned,earned/(DATE_DIFF('day', i.created_at, coalesce(e.exited_at,current_date))) earned_per_dayfrom info_created ileft join info_exited e on i.pubkey = e.pubkeyleft join info_earned m on m.pubkey = i.pubkey)selectage,status,count(*) nfrom final