Query editor
with airdrop as (selectt."to" as receiver,sum(t.value / 1e18) as airdrop_amountfrom erc20_ethereum.evt_transfer twhere t.contract_address = 0x000006c2a22ff4a44ff1f5d0f2ed65f781f55555 -- ZKCand t.evt_tx_from = 0x7cc3376b8d38b2c923cd9d5164f9d74e303482b2 -- airdrop 发起者and t.evt_tx_to = 0xd152f549545093347a162dce210e7293f1452150 -- Disperseand t."to" <> 0xd152f549545093347a162dce210e7293f1452150 -- 排除 Disperse 自己group by t."to"),sold as (selectt."from" as seller,min(t.evt_block_time) as first_sold_time,max(t.evt_block_time) as last_sold_time,sum(t.value / 1e18) as total_sold_amountfrom erc20_ethereum.evt_transfer twhere t.contract_address = 0x000006c2a22ff4a44ff1f5d0f2ed65f781f55555group by t."from"),detail as (selecta.receiver,a.airdrop_amount,coalesce(s.total_sold_amount, 0) as total_sold_amount,(a.airdrop_amount - coalesce(s.total_sold_amount, 0)) as current_balance,case when s.seller is not null then 1 else 0 end as has_soldfrom airdrop aleft join sold s on a.receiver = s.seller),bucketed as (select*,casewhen airdrop_amount between 100 and 500 then '100-500'when airdrop_amount between 501 and 1000 then '501-1000'when airdrop_amount between 1001 and 2000 then '1001-2000'when airdrop_amount between 2001 and 3000 then '2001-3000'when airdrop_amount between 3001 and 4000 then '3001-4000'when airdrop_amount between 4001 and 5000 then '4001-5000'when airdrop_amount between 5001 and 5999 then '5001-5999'when airdrop_amount = 6000 then '6000'else 'other'end as airdrop_bucketfrom detail)selectairdrop_bucket,count(*) as total_receivers,count_if(has_sold = 1) as total_sellers,round(100.0 * count_if(has_sold = 1) / count(*), 2) as seller_ratio_percent,sum(airdrop_amount) as total_airdrop_amount,sum(total_sold_amount) as total_sold_amount,sum(current_balance) as total_remainingfrom bucketedgroup by airdrop_bucketorder by min(airdrop_amount);