Query editor
with raw as (select"from" as address,-value / 1e6 as amountfrom erc20_ethereum.evt_transferwhere contract_address = 0xd9b2cb2fbad204fc548787ef56b918c845fcce40union allselect"to" as address,value / 1e6 as amountfrom erc20_ethereum.evt_transferwhere contract_address = 0xd9b2cb2fbad204fc548787ef56b918c845fcce40),holder as (selectaddress,sum(amount) as usdc_depositedfrom rawwhere address <> 0x0000000000000000000000000000000000000000group by 1having sum(amount) > 0 -- only active depositors),buckets as (selectcasewhen usdc_deposited <= 100 then '0 – 100'when usdc_deposited <= 1000 then '101 – 1,000'when usdc_deposited <= 10000 then '1,001 – 10,000'when usdc_deposited <= 100000 then '10,001 – 100,000'when usdc_deposited <= 1000000 then '100,001 – 1,000,000'else '1,000,001 and above'end as deposit_range,usdc_depositedfrom holder)selectdeposit_range,count(*) as num_depositors,round(sum(usdc_deposited), 2) as total_usdc,round(avg(usdc_deposited), 2) as avg_deposit,round(sum(usdc_deposited) / total_vault_supply * 100,4) as pct_of_totalfrom bucketscross join (select sum(usdc_deposited) as total_vault_supply from holder) tgroup by deposit_range, total_vault_supplyorder bycase deposit_rangewhen '0 – 100' then 1when '101 – 1,000' then 2when '1,001 – 10,000' then 3when '10,001 – 100,000' then 4when '100,000 – 1,000,000' then 5when '1,000,001 and above' then 6end;