Query editor
WITH ordered_stakes AS(SELECTparticipant,SUM(amt) as total_lockFROM(SELECT participant, (cast(amount as double) / 10000) as amt FROM airswap_ethereum."Locker_evt_Lock"UNION ALLSELECT participant, (cast(amount as double) / -10000) as amt FROM airswap_ethereum."Locker_evt_Unlock"UNION ALLSELECT "to" as participant, (cast(tokens as double) / 10000) as amt FROM airswap_ethereum."sAST_evt_Transfer"WHERE "to" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "from" as participant, (cast(tokens as double) / -10000) as amt FROM airswap_ethereum."sAST_evt_Transfer"WHERE "from" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "to" as participant, (cast(tokens as double) / 10000) as amt FROM airswap_ethereum."Staking_v3_evt_Transfer"WHERE "to" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "from" as participant, (cast(tokens as double) / -10000) as amt FROM airswap_ethereum."Staking_v3_evt_Transfer"WHERE "from" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "to" as participant, (cast(tokens as double) / 10000) as amt FROM airswap_ethereum."Staking_v4_evt_Transfer"WHERE "to" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "from" as participant, (cast(tokens as double) / -10000) as amt FROM airswap_ethereum."Staking_v4_evt_Transfer"WHERE "from" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "to" as participant, (cast(tokens as double) / 10000) as amt FROM airswap_ethereum."Staking_v4_2_evt_Transfer"WHERE "to" != 0x0000000000000000000000000000000000000000UNION ALLSELECT "from" as participant, (cast(tokens as double) / -10000) as amt FROM airswap_ethereum."Staking_v4_2_evt_Transfer"WHERE "from" != 0x0000000000000000000000000000000000000000) as lock_unlockGROUP BY participant),bins as (selectfloor(log(5, total_lock)) as bin_floor,count(participant) as countfrom ordered_stakeswhere total_lock > 1group by 1order by 1)SELECTbin_floor,format_number(power(5, cast(bin_floor as integer))) || ' - ' || format_number(power(5,cast(bin_floor + 1 as integer))) as bin_range,countfrom binsorder by 1;