Query editor
with all_ohm_trades as (selectdate_trunc('week',block_date) as week, CASEWHEN token_sold_address = 0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5 THEN 'sell'WHEN token_bought_address = 0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5 THEN 'buy'END as action, token_bought_symbol, token_sold_symbol, token_pair, token_bought_amount, token_sold_amount, amount_usd, token_bought_address, token_sold_address, project_contract_address, tx_hash, tx_from, tx_to, evt_indexfrom dex.tradeswhere block_date > cast('2022-11-22' as timestamp)and token_bought_address = 0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5 or token_sold_address = 0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5),buys as (selectweek, sum(amount_usd) as sum_boughtfrom all_ohm_tradeswhere action = 'buy'group by 1),sells as (selectweek, sum(amount_usd) as sum_soldfrom all_ohm_tradeswhere action = 'sell'group by 1)selectA.week, A.sum_bought, B.sum_sold, A.sum_bought - B.sum_sold as buy_sell_differencefrom buys Aleft join sells B on A.week = B.weekorder by 1 desc