Query editor
WITH deposits AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value) / POWER(10, 6) AS depositFROM erc20_ethereum.evt_TransferWHEREcontract_address = 0xdd4d117723C257CEe402285D3aCF218E9A8236E1AND "from" = 0x0000000000000000000000000000000000000000GROUP BY1), withdrawals AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value) / POWER(10, 6) AS withdrawalFROM erc20_ethereum.evt_TransferWHEREcontract_address = 0xdd4d117723C257CEe402285D3aCF218E9A8236E1AND "to" = 0x0000000000000000000000000000000000000000GROUP BY1), time_series AS (SELECTdays_tsFROM UNNEST(SEQUENCE(TRY_CAST('2021-10-14' AS DATE), CURRENT_DATE) /* WARNING: Check out the docs for example of time series generation: https://dune.com/docs/query/syntax-differences/ */) AS t(days_ts)), combo1 AS (SELECTtime_series.days_ts AS days_ts,COALESCE(deposits.deposit, 0) AS deposit,COALESCE(withdrawals.withdrawal, 0) AS withdrawalFROM time_seriesLEFT JOIN depositsON deposits.day = time_series.days_tsLEFT JOIN withdrawalsON withdrawals.day = time_series.days_ts), combo2 AS (SELECTdays_ts,SUM((deposit) - (withdrawal)) OVER (ORDER BY days_ts) AS sum1FROM combo1)SELECT*FROM combo2ORDER BY1