Query editor
with lp_total as (select sum(balance) as balance from query_2850359),staking_total as (select sum(balance) as balance from query_2850394),total_balance as (select (coalesce(lp_total.balance, 0) + coalesce(staking_total.balance, 0)) as total from lp_total cross join staking_total),arx_balance as (select output__reserve0/1e18 as reserve from arx_arbitrum.ArbDexPair_call_getReserves where contract_address = 0xA6efAE0C9293B4eE340De31022900bA747eaA92D and call_success = true order by call_block_number desc limit 1),-- Adding total ARX held by all wallets as the first rowall_totals as (select0x0000000000000000000000000000000000000000 as account,sum(balance) as balance,100 as ratio,sum(arx) as arxfrom (selectcoalesce(lp.account, staking.account) as account, (coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) as balance,((coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) / total_balance.total * 100) as ratio,(((coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) / total_balance.total) * arx_balance.reserve) as arxfrom query_2850359 as lpfull join query_2850394 as staking on lp.account = staking.accountcross join total_balancecross join arx_balance) sub_query)select account, balance, ratio, arx from all_totalsUNION ALL-- Individual balancesselectcoalesce(lp.account, staking.account) as account, (coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) as balance,((coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) / total_balance.total * 100) as ratio,(((coalesce(lp.balance, 0) + coalesce(staking.balance, 0)) / total_balance.total) * arx_balance.reserve) as arxfrom query_2850359 as lpfull join query_2850394 as staking on lp.account = staking.accountcross join total_balancecross join arx_balanceorder by balance desc;