Query editor
-- from 0xtayasawith track_contract as((selectdate_trunc('day', "evt_block_time") as period,"to" as wallet,count("to") as interactionfrom erc1155_polygon.evt_TransferSinglewhere contract_address=0x0B5cfed5efB6f831468B8b5b5321B71825a2AEe0 --loot contractand "from" =0x0000000000000000000000000000000000000000and cast(id as varchar) !='3' and cast(id as varchar) !='100000' --exclude retriever drone and Balanced Drone Chassis - Limited Edition--and((extract(year from now())-extract(year from "evt_block_time")) * 12 + extract(month from now())- extract(month from"evt_block_time")) <12--trailling 12 monthsgroup by 1,2order by 1)union all(select period, wallet, count(wallet) as interaction from(select distinct "evt_tx_hash" as hash,date_trunc('day', "evt_block_time") as period,"to"as walletfrom(select *from erc1155_polygon.evt_TransferBatchcross join unnest("ids","values") as tbl(id,value)where contract_address=0x0B5cfed5efB6f831468B8b5b5321B71825a2AEe0and "from" = 0x0000000000000000000000000000000000000000and cast(id as varchar) !='3' and cast(id as varchar) !='100000' --exclude retriever drone and Balanced Drone Chassis - Limited Edition))group by 1,2)),first_interaction as (select wallet, min(period) as first_day from track_contract group by 1)select t.period,count(distinct t.wallet) as uaw, count(distinct t.wallet)-count(distinct ft.wallet) as return_uaw,count(distinct ft.wallet) as new_uaw,AVG(count(distinct t.wallet)) OVER (ORDER BY t.period ASC ROWS BETWEEN 2 PRECEDING AND CURRENT ROW ) AS "3-Period SMA",sum(cast(interaction as double))/count(t.wallet) as avg_intereaction,count(distinct case when (interaction=1) then t.wallet end) as "Interaction Once",count(distinct case when (interaction>=2 and interaction<=4) then t.wallet end) as ">=2 Interaction <=4 ",count(distinct case when (interaction>=5 and interaction<=9) then t.wallet end) as ">=5 Interaction <=9 ",count(distinct case when (interaction>=10 and interaction<=19) then t.wallet end) as ">=10 Interaction <=19 ",count(distinct case when (interaction>=20) then t.wallet end) as "Interaction >=20"from(select period,wallet,sum(interaction) as interactionfrom track_contractgroup by 1,2)tleft join first_interaction ft on t.period=ft.first_daywhere period > now() - interval '{{Trailing Days}}' dayand 1 <= {{Synchronize}}group by 1