Query editor
SELECTtrader,SUM(CASEWHEN isBuy = true THEN - (CAST(ethAmount AS DECIMAL (38, 0)) + CAST(protocolEthAmount AS DECIMAL (38, 0)) + CAST(subjectEthAmount AS DECIMAL (38, 0)))ELSE (CAST(ethAmount AS DECIMAL (38, 0)) - CAST(protocolEthAmount AS DECIMAL (38, 0)) - CAST(subjectEthAmount AS DECIMAL (38, 0)))END)/1e18 AS total_profitFROMfriendtech_base.FriendtechSharesV1_evt_TradeGROUP BYtraderORDER BYtotal_profit DESC;