Query editor
WITH stkAAVE_withdrawn AS (SELECTDATE(evt_block_time) AS day,SUM((shares / 1e18)) AS total_stkaave_withdrawnFROM aave_ethereum.stkAAVE_evt_RedeemWHEREevt_block_time > (CURRENT_TIMESTAMP - INTERVAL '59' DAY -- adjust as necessary)GROUP BYDATE(evt_block_time)),stkAAVE_deposited AS (SELECTDATE(evt_block_time) AS day,SUM((shares / 1e18)) AS total_stkaave_depositedFROM aave_ethereum.stkAAVE_evt_StakedWHEREevt_block_time > (CURRENT_TIMESTAMP - INTERVAL '59' DAY -- adjust as necessary)GROUP BYDATE(evt_block_time))SELECTCOALESCE(stkAAVE_deposited.day, stkAAVE_withdrawn.day) as day,COALESCE(stkAAVE_deposited.total_stkaave_deposited, 0) - COALESCE(stkAAVE_withdrawn.total_stkaave_withdrawn, 0) AS daily_net_flow_stkAAVE,stkAAVE_deposited.total_stkaave_deposited,stkAAVE_withdrawn.total_stkaave_withdrawnFROMstkAAVE_depositedFULL OUTER JOIN stkAAVE_withdrawn ON stkAAVE_deposited.day = stkAAVE_withdrawn.dayORDER BY day DESC;