Query editor
-- Query Name: monthly_pyusd_usd_volume_net_flow_ethereumSELECTDATE_TRUNC('month', block_time) AS month,-- Buy volume in USD: sum of 'amount_usd' where PYUSD is boughtSUM(CASEWHEN token_bought_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8THEN amount_usdELSE 0END) AS buy_vol_usd,-- Sell volume in USD: sum of 'amount_usd' where PYUSD is soldSUM(CASEWHEN token_sold_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8THEN amount_usdELSE 0END) AS sell_vol_usd,-- Net flow in USD = total bought (PYUSD) - total sold (PYUSD)SUM(CASEWHEN token_bought_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8THEN amount_usdELSE 0END) -SUM(CASEWHEN token_sold_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8THEN amount_usdELSE 0END) AS net_flow_usdFROMdex.tradesWHERE(token_bought_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8 ORtoken_sold_address = 0x6c3ea9036406852006290770BEdFcAbA0e23A0e8)-- Optional: last 6 months onlyAND block_time >= DATE_ADD('month', -6, CURRENT_TIMESTAMP)GROUP BY1ORDER BYmonth DESC;