Query editor
WITH all_trades AS (SELECT DISTINCTdt.hash as tx_hash,dt."from" as tx_from,DATE(dt.block_time) as trade_dateFROM bnb.transactions dtWHERE dt.to = 0xb300000b72deaeb607a12d5f54773d1c19c7028dAND dt.block_time > now() - INTERVAL '90' day),fee_transfers AS (SELECTtx_hash,-- amount as fee_amount_bnb,amount_usd as fee_amount_usdFROM tokens_bnb.transfersWHERE to in (0xB9B2D319A9249486c0F4c7831f912db5aEE4C595,0x94a11745a8d33388ee635b55f43944f1202c13d4) AND block_time > now() - INTERVAL '180' day),all_trades_with_fee AS (SELECTwt.*,-- ft.fee_amount_bnb,ft.fee_amount_usdFROM all_trades wtINNER JOIN fee_transfers ft ON wt.tx_hash = ft.tx_hash)-- 按日期聚合统计SELECTtrade_date,COUNT(DISTINCT tx_hash) as daily_trade_count,COUNT(DISTINCT tx_from) as daily_unique_traders,-- SUM(fee_amount_bnb) as daily_fee_bnb,SUM(fee_amount_usd) as daily_fee_usd, -- 每日交易费金额SUM(SUM(fee_amount_usd)) OVER (ORDER BY trade_date) as cumulative_fee_usd -- 累积交易费金额FROM all_trades_with_feeGROUP BY trade_dateORDER BY trade_date DESC