Query editor
withgs AS (SELECT dayFROMUNNEST(sequence(TIMESTAMP '2022-03-21', CAST(current_date AS timestamp), INTERVAL '1' day)) tbl (day)) ,getbalance2 as (selectday,'APE' token,sum(amount) over (order by day) balancefrom (selectday,sum(amount) amountfrom (selectdate_trunc('day', evt_block_time) as day,sum(assets/1e18) amountfrom bend_ethereum.BendCoinPool_evt_Depositgroup by 1union allselectdate_trunc('day', evt_block_time) as day,sum(assets/1e18) amountfrom bend_ethereum.BendCoinPool_evt_Withdrawgroup by 1)group by 1)),setLeadData2 AS (SELECT*, lead(day, 1, NOW()) OVER (PARTITION BY "token" ORDER BY day ASC) latest_dayFROMgetBalance2)SELECTCAST(gs.day AS timestamp) day,token,balanceFROM(setLeadData2 gINNER JOIN gs ON ((g.day <= gs.day) AND (gs.day < g.latest_day)))order by 1 desc