Query editor
with account_connection as (select distinct * from(select primaryAccount as account , subAccount from hmx_arbitrum.TradeService_evt_LogIncreasePosition)),size as (select ac.account as account , sum(coalesce(size.size,0))/1e30 as size from account_connection acleft join(select subAccount , sum(size) as size from((select subAccount, abs(cast(increasedSize as double)) as size from hmx_arbitrum.TradeService_evt_LogIncreasePositiongroup by subAccount and size)union all(select subAccount,abs(cast(decreasedSize as double)) as size from hmx_arbitrum.TradeService_evt_LogDecreasePositiongroup by subAccount)union all(select subAccount, abs(cast(closedPositionSize as double)) as size from hmx_arbitrum.TradeService_evt_LogForceClosePositiongroup by subAccount)union all(select subAccount, abs(cast(size as double)) as size from hmx_arbitrum.LiquidationService_evt_LogLiquidationPositiongroup by subAccount))group by subAccount) sizeon ac.subAccount = size.subAccountgroup by ac.account)select row_number() over (order by pnl.pnl desc) as "rank", ac.account, size.size as Volume from account_connection acleft join sizeon ac.account = size.accountorder by size desc