Query editor
WITH trades AS (SELECTt.block_date AS day,CASEWHEN t.token_bought_address = e.contract_address THEN 'BUY'WHEN t.token_sold_address = e.contract_address THEN 'SELL'END AS trade_type,t.taker,e.symbolFROM dex.trades tJOIN tokens.erc20 eON (t.token_bought_address = e.contract_addressOR t.token_sold_address = e.contract_address)WHERE t.blockchain = 'ethereum'AND e.symbol = 'USDC'AND t.block_date >= current_date - interval '10' dayLIMIT 50)SELECTday,SUM(CASE WHEN trade_type IN ('BUY', 'SELL') THEN 1 ELSE 0 END) AS total_transactions,SUM(CASE WHEN trade_type = 'BUY' THEN 1 ELSE 0 END) AS buy_transactions,SUM(CASE WHEN trade_type = 'SELL' THEN 1 ELSE 0 END) AS sell_transactions,COUNT(DISTINCT CASE WHEN trade_type = 'BUY' THEN taker END) AS buyers,COUNT(DISTINCT CASE WHEN trade_type = 'SELL' THEN taker END) AS sellersFROM tradesWHERE trade_type IS NOT NULLGROUP BY dayORDER BY day DESC