Query editor
WITH all_swaps AS (SELECT * FROM dex.trades WHERE project_contract_address = 0x19d89a557ce82a0d487a83e3081e37fa5af2388e),Buys AS (SELECTtx_from,SUM(amount_usd) AS total_buyFROMall_swapsWHEREtoken_bought_address = 0xBc8b7Ff89EB2B73eCDD579F81424a3B582200808GROUP BYtx_from),Sells AS (SELECTtx_from,SUM(amount_usd) AS total_sellFROMall_swapsWHEREtoken_bought_address = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2GROUP BYtx_from)SELECTb.tx_from,total_buy,total_sell,(total_sell - total_buy ) as profitFROMBuys bleft JOINSells s ON b.tx_from = s.tx_fromorder by profit desc;