Query editor
with labels as (select distinct address,name from labels.allwhere blockchain = 'ethereum'and category in ('contract','social','institution','hackers','infrastructure','dao','ofac_sanction','bridge','dao','project wallet','hackers','Rollup','infrastructure')and (label_type = 'identifier' or (label_type = 'persona' and model_name = 'dao_framework'))union allselect * from query_2640605union allselect address, exchange as namefrom query_2296923),current_bal as (select address, sum(amount) as amount from (select "to" as address, sum(cast(value as double)/1e18) as amountfrom erc20_ethereum.evt_Transferwhere contract_address = 0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050and "to" in (select distinct "to" as receiverfrom erc20_ethereum.evt_Transferwhere contract_address = 0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050and "from" = 0x08c7676680F187A31241E83e6d44C03A98AdaB05)group by 1union allselect "from" as address, sum(cast(value as double)/1e18*-1) as amountfrom erc20_ethereum.evt_Transferwhere contract_address = 0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050and "from" in (select distinct "to" as receiverfrom erc20_ethereum.evt_Transferwhere contract_address = 0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050and "from" = 0x08c7676680F187A31241E83e6d44C03A98AdaB05)group by 1) agroup by 1)select rank() over (order by airdrop_amount desc) as ranking,*from (selectCONCAT('<a href="https://etherscan.io/address/', cast("to" as varchar), '" target="_blank">',cast("to" as varchar), '</a>') as address,"to",array_Agg(distinct name) as labels,casewhen sum(cast(value as double)/1e18)>amount then 'Sold'when sum(cast(value as double)/1e18)=amount then 'HODL'when sum(cast(value as double)/1e18)<amount then 'Bought'end as balance_change,sum(cast(value as double)/1e18) as airdrop_amount, sum(cast(value as double)/1e18)/30000000 as allocation,amount as current_balance, amount-sum(cast(value as double)/1e18) as deltafrom erc20_ethereum.evt_Transfer aleft join labels bon "to" = b.addressleft join current_bal con "to" = c.addresswhere contract_address = 0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050