Query editor
with date_filter as (select (casewhen '{{date_period}}' = '7 Days' then now() - interval '7' daywhen '{{date_period}}' = '30 Days' then now() - interval '30' daywhen '{{date_period}}' = '3 Months' then now() - interval '3' monthwhen '{{date_period}}' = '6 Months' then now() - interval '6' monthelse date('2022-05-18')end) as start_date),profile_created as (select evt_block_time,evt_tx_hash,profileId,handle,"to" as ownerfrom lens_polygon.LensHub_evt_ProfileCreated pinner join date_filter on truewhere evt_block_time >= date_filter.start_date),profile_burned as (select evt_block_time,evt_tx_hash,"from" as owner,tokenId as profileIdfrom lens_polygon.LensHub_evt_Transfer tinner join date_filter on truewhere evt_block_time >= date_filter.start_dateand "to" = 0x0000000000000000000000000000000000000000),daily_profile_summary as (select date_trunc('day', c.evt_block_time) as block_date,count(c.profileId) as create_profile_count,count(b.profileId) as burn_profile_countfrom profile_created cleft join profile_burned b on c.profileId = b.profileIdgroup by 1order by 1)select block_date,coalesce(create_profile_count, 0) as create_profile_count,coalesce(burn_profile_count, 0) as burn_profile_count,sum(create_profile_count) over (order by block_date) as accumulate_create_profile_count,sum(burn_profile_count) over (order by block_date) as accumulate_burn_profile_count,sum(coalesce(create_profile_count, 0) - coalesce(burn_profile_count, 0)) over () as total_profile_countfrom daily_profile_summaryorder by block_date