Query editor
WITH transfers AS (SELECT"from" AS from_address,"to" AS to_address,value / 1e18 AS value,evt_block_time as block_timeFROM erc20_bnb.evt_transferWHERE contract_address=0x20d6015660b3fe52e6690a889b5C51F69902cE0eAND value > 0 -- 仅统计 S 代币转账),all_cex_addresses AS (SELECT address FROM query_4797805),daily_flows AS (-- 计算整个合集的每日流入、流出和净流入SELECTdate, -- 直接用 dateSUM(daily_inflow) AS daily_inflow, -- 合集内所有地址的总流入SUM(daily_outflow) AS daily_outflow, -- 合集内所有地址的总流出SUM(daily_net_inflow) AS daily_net_inflow -- 合集内所有地址的净流入FROM (-- 先计算 date,再用于流入和流出查询SELECTDATE_TRUNC('day', block_time) AS date,value AS daily_inflow,0 AS daily_outflow,value AS daily_net_inflowFROM transfersWHERE to_address IN (SELECT address FROM all_cex_addresses) -- 替换为合集的地址列表UNION ALLSELECTDATE_TRUNC('day', block_time) AS date,0 AS daily_inflow,value AS daily_outflow,-value AS daily_net_inflowFROM transfersWHERE from_address IN (SELECT address FROM all_cex_addresses) -- 替换为合集的地址列表) tGROUP BY date),cumulative_flows AS (-- 计算合集的累计净流入SELECTdate,daily_inflow,daily_outflow,daily_net_inflow,SUM(daily_net_inflow) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_net_inflowFROM daily_flows)SELECTdate,daily_inflow,daily_outflow,daily_net_inflow,cumulative_net_inflowFROM cumulative_flowsORDER BY date DESC;