Query editor
WITH buy AS (SELECTtrader_id AS user,MIN(block_time) AS first_buy_time,SUM(token_bought_amount) AS amount_bought,SUM(amount_usd) AS amount_bought_usdFROMdex_solana.tradesWHERE token_bought_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'GROUP BY 1),sell AS (SELECTtrader_id AS user,MIN(block_time) AS first_sell_time,SUM(token_sold_amount) AS amount_sold,SUM(amount_usd) AS amount_sold_usdFROMdex_solana.tradesWHERE token_sold_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'GROUP BY 1),combined AS (SELECTCOALESCE(buy.user, sell.user) AS user,COALESCE(buy.amount_bought, 0) - COALESCE(sell.amount_sold, 0) AS net_tokens_bought,COALESCE(buy.amount_bought_usd, 0) AS amount_bought_usd,COALESCE(sell.amount_sold_usd, 0) AS amount_sold_usd,COALESCE(sell.amount_sold_usd, 0) - COALESCE(buy.amount_bought_usd, 0) AS profitability,LEAST(buy.first_buy_time, sell.first_sell_time) AS first_trade_time,GREATEST(buy.first_buy_time, sell.first_sell_time) AS last_trade_time,COALESCE(buy.amount_bought, 0) AS amount_bought,COALESCE(sell.amount_sold, 0) AS amount_soldFROMbuyFULL OUTER JOINsell ON sell.user = buy.user),latest_balance AS (SELECTaddress,token_balanceFROMsolana_utils.latest_balancesWHEREtoken_mint_address = 'EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm')SELECTc.user,c.net_tokens_bought,c.amount_bought_usd,c.amount_sold_usd,c.amount_bought,c.amount_sold,c.profitability,c.first_trade_time,