Query editor
WITH trades AS (SELECT -- buyblock_date,block_time,'BUYS' as action,token_bought_amount AS amt,amount_usd AS usd,amount_usd/token_bought_amount AS priceFROM dex.tradesWHERE token_bought_address = 0xCA5b0AE1d104030a9B8F879523508EFd86c14483AND amount_usd IS NOT NULLUNION ALLSELECT --sellblock_date,block_time,'SELLS' as action,token_sold_amount AS amt,amount_usd AS usd,amount_usd/token_sold_amount AS priceFROM dex.tradesWHERE token_sold_address = 0xCA5b0AE1d104030a9B8F879523508EFd86c14483AND amount_usd IS NOT NULL)selectblock_date,action,sum(amt) as total_amount,sum(usd) as usd_volume,sum(usd)/sum(amt) as avg_pricefrom tradesgroup by block_date, actionorder by block_date desc