Query editor
WITH data AS (SELECTcow_protocol_ethereum.trades.block_time AS time,sell_token AS token_from,buy_token AS token_to,usd_value,surplus_usd,'eth' AS blockchain,trader AS user,cow_protocol_ethereum.trades.tx_hash,cow_protocol_ethereum.trades.sell_token_address AS token_from_addr,cow_protocol_ethereum.trades.buy_token_address AS token_to_addrFROMcow_protocol_ethereum.tradesLEFT JOINcow_protocol_ethereum.batches ON cow_protocol_ethereum.trades.tx_hash = cow_protocol_ethereum.batches.tx_hashWHEREusd_value IS NOT NULLAND cow_protocol_ethereum.trades.block_time >= NOW() - INTERVAL '168' HOURAND buy_token NOT LIKE '%0x%'AND sell_token NOT LIKE '%0x%'ORDER BYtime DESC)SELECTtoken_from,token_to,token_from_addr,token_to_addr,COUNT(*) AS count,AVG(usd_value) AS avg_valueFROMdataGROUP BYtoken_from,token_to,token_from_addr,token_to_addrORDER BYcount DESC