Query editor
with incoming as (select sum(value) / 1e18 as value, "to" as accountfrom erc20_arbitrum.evt_Transferwhere "from" = 0x0000000000000000000000000000000000000000and contract_address = 0x86B89ce3190724E370313a63D528F444627575B8group by 2), outgoing as (select sum(value) / 1e18 as value, "from" as accountfrom erc20_arbitrum.evt_Transferwhere "to" = 0x0000000000000000000000000000000000000000and contract_address = 0x86B89ce3190724E370313a63D528F444627575B8group by 2), total as (selectincoming.account,(incoming.value - coalesce(outgoing.value, 0)) as balancefromincomingleft joinoutgoing on (incoming.account = outgoing.account)), incoming_arx as (select sum(value) / 1e18 * 0.99 as valuefrom erc20_arbitrum.evt_Transferwhere "from" = 0x398c69c44106e41e1f2293f15ce9ecd3f371179fand "to" = 0xe633C4321B066c1348B8D1694461Bc58161a8125and contract_address = 0xD5954c3084a1cCd70B4dA011E67760B8e78aeE84), outgoing_arx as (select sum(value) / 1e18 as valuefrom erc20_arbitrum.evt_Transferwhere "from" = 0xe633C4321B066c1348B8D1694461Bc58161a8125and "to" = 0x398c69c44106e41e1f2293f15ce9ecd3f371179fand contract_address = 0xD5954c3084a1cCd70B4dA011E67760B8e78aeE84), total_arx as (select (coalesce(incoming_arx.value, 0) - coalesce(outgoing_arx.value, 0)) as totalfrom incoming_arx cross join outgoing_arx), ac_total as (select sum(balance) as balance from total)-- Adding total staked amount as the first rowselect 0x0000000000000000000000000000000000000000 as account, sum(balance) as balance, 100 as ratio, total_arx.total as arx from total cross join total_arxwherebalance > 0group by total_arx.totalUNION ALL-- Individual balancesselect total.account, total.balance, (total.balance / ac_total.balance * 100) as ratio, (total.balance / ac_total.balance) * total_arx.total as arx from total cross join ac_total cross join total_arxwheretotal.balance > 0order by balance desc;