select
date_trunc('day', block_timestamp)::date as date,
LABEL_TYPE,
count(tx_hash) as tx_count,
sum(tx_FEE) as fees,
fees/tx_count as fee_per_tx,
sum(fees)over( partition by LABEL_TYPE order by date rows between unbounded preceding and current row ) as cum_fees
from avalanche.core.fact_transactions t,avalanche.core.dim_labels l
where t.TO_ADDRESS = l.address
and
BLOCK_TIMESTAMP:: date >= '2022-07-01'
and LABEL_TYPE != 'token'
group by 1,2 order by 1