Query editor
with wallets_min as (SELECT min(block_time) as min_block_time, "to" as address, sum(cast(value as DOUBLE)) / 1e18 as ethFROM ethereum.transactionsGROUP By 2),wallets_3d as (SELECT block_time, "to" as address, sum(cast(value as DOUBLE)) / 1e18 as ethFROM ethereum.transactionswhere block_time > CURRENT_TIMESTAMP - INTERVAL '4' day --GROUP By 1,2),wallets_3d_filter as (SELECT * FROM wallets_3dwhere eth > 0.02),-- removinf block time, eth, and min blovk time to derive distinct fieldsfresh_wallets_list as (select--w3d.block_time,DATE_TRUNC('day', w3d.block_time) as dates,w3d.address,--w3d.eth,--wm.min_block_time,date_diff('day', wm.min_block_time, w3d.block_time) AS difffromwallets_3d_filter w3dleft join wallets_min wm on w3d.address = wm.address),wallets_list as (selectdistinct fresh_wallets_list.*from fresh_wallets_listwhere diff = 0 --and address in (0x584d014f6ec14fdbbcfac2dfd4f550ce419c16de, 0x152af387829850b2f55705f790e9b2d732662e3a, 0x006688e1191c76b76e135b11e1eebfc7da6ac061,0x008cb8a501e7e7cbea2cf3f878230adcef83bf66)),setLeadData as (SELECT *,lead(dates,1,NOW()) OVER (PARTITION BY address ORDER BY dates) as latest_day FROM wallets_list),gs as (SELECT date FROM UNNEST(sequence(TIMESTAMP '2023-08-04',CURRENT_DATE,interval '1' day)) as tbl(date))select date,address,diff FROM (SELECT date,address,diff,row_number() over (partition by address order by date) as rnFROM setLeadData gINNER JOIN gs ON g.dates <= gs.date AND gs.date < g.latest_day)where rn IN (1,2,3,4)