Query editor
with incoming as (select sum(value) / 1e18 as value, "to" as accountfrom erc20_arbitrum.evt_Transferwhere "from" = 0x0000000000000000000000000000000000000000and contract_address = 0xDA594c20925712d60d0e7f8D70c9b8586bcd353fgroup by 2), outgoing as (select sum(value) / 1e18 as value, "from" as accountfrom erc20_arbitrum.evt_Transferwhere "to" = 0x0000000000000000000000000000000000000000and contract_address = 0xDA594c20925712d60d0e7f8D70c9b8586bcd353fgroup 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" = 0xe19f481dbfb9050b7c95c33a21f99f60c5ee19eeand "to" = 0xf4752a5f352459948620e7C377b10ddcC92015c8and contract_address = 0xD5954c3084a1cCd70B4dA011E67760B8e78aeE84), outgoing_arx as (select sum(value) / 1e18 as valuefrom erc20_arbitrum.evt_Transferwhere "from" = 0xf4752a5f352459948620e7C377b10ddcC92015c8and "to" = 0xe19f481dbfb9050b7c95c33a21f99f60c5ee19eeand 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;