Query editor
with init as (select block_time as block_time, tx_from as userfrom uniswap_v3_ethereum.tradesunion allselect block_time as block_time, tx_to as userfrom uniswap_v3_ethereum.trades),new as(select month,new_user,sum(new_user) over( order by month) as total_new_user from(select date_trunc('month',min_block_time) as month,count(distinct user) as new_user from(select user,min(block_time) as min_block_time from init group by 1) as pgroup by 1) q),total as (select block_time,user,row_number() over (partition by user order by block_time) as row_num,date_diff('day',lag(block_time) over (partition by user order by block_time),block_time) as difffrom init),final as(select date_trunc('month',block_time) as month,count(distinct user) as month_retention fromtotal where diff<=30 and row_num>=2group by 1)select new.month,month_retention,total_new_user,cast(month_retention*100 as real)/cast(total_new_user as REAL) as monthly_retention_ratefromnewleft joinfinalon new.month=final.monthorder by 1