Query editor
WITHdaily_buy AS (SELECTDATE_TRUNC('day', block_time) AS day,SUM(amount_usd) AS "Total Buy Value",SUM(token_bought_amount) AS total_osETH_boughtFROM dex.tradesWHERE token_bought_address = 0xf1c9acdc66974dfb6decb12aa385b9cd01190e38GROUP BY 1),daily_sell AS (SELECTDATE_TRUNC('day', block_time) AS day,SUM(amount_usd) AS "Total Sell Value",SUM(token_sold_amount) AS total_osETH_soldFROM dex.tradesWHERE token_sold_address = 0xf1c9acdc66974dfb6decb12aa385b9cd01190e38GROUP BY 1),joined AS (SELECTb.day AS day,b."Total Buy Value" AS "Total Buy Value",b.total_osETH_bought AS total_osETH_bought,s."Total Sell Value" * -1 AS "Total Sell Value",s.total_osETH_sold * -1 AS total_osETH_sold,b.total_osETH_bought - s.total_osETH_sold AS osETH_wise_delta,b."Total Buy Value" - s."Total Sell Value" AS dollar_wise_delta,b."Total Buy Value" + s."Total Sell Value" AS "Total Volumes"FROM daily_buy bLEFT JOIN daily_sell s ON b.day = s.day)SELECT * FROM joinedORDER BY day DESC