Query editor
WITH deposits AS (SELECT-- 4-hour bucketdate_trunc('hour', evt_block_time)- ((extract(HOUR FROM evt_block_time) % 4)* INTERVAL '1' HOUR) AS bucket_4h,SUM(amount / 1e18) AS deposit_ethFROM aztec_caa_sale_ethereum.continuousclearingauction_evt_bidsubmittedWHERE evt_block_time >= CAST('{{after this time}}' AS timestamp)GROUP BY 1),withdraws AS (SELECT-- 4-hour bucketdate_trunc('hour', evt_block_time)- ((extract(HOUR FROM evt_block_time) % 4)* INTERVAL '1' HOUR) AS bucket_4h,SUM(currencyRefunded / 1e18) AS withdraw_ethFROM aztec_caa_sale_ethereum.continuousclearingauction_evt_bidexitedWHERE evt_block_time >= CAST('{{after this time}}' AS timestamp)GROUP BY 1),combined AS (SELECTCOALESCE(d.bucket_4h, w.bucket_4h) AS bucket_4h,COALESCE(d.deposit_eth, 0) AS deposit_eth,COALESCE(w.withdraw_eth, 0) AS withdraw_eth,COALESCE(d.deposit_eth, 0) - COALESCE(w.withdraw_eth, 0) AS net_ethFROM deposits dFULL OUTER JOIN withdraws wON d.bucket_4h = w.bucket_4h)SELECTbucket_4h,deposit_eth,withdraw_eth,net_eth,SUM(net_eth) OVER (ORDER BY bucket_4h) AS cumulative_net_ethFROM combinedORDER BY bucket_4h;