# Rolling Sum of Daily Transfers

The next step is to apply the rolling sum window function to each daily transfer sum. This is a pretty straightforward query. We’d end here for balances if it was guaranteed that each wallet/contract pair made a transfer every day. But since that’s not the case we’ll finish the Spell in the next model by filling in all the missing days and doing a few more clean up steps.

transfers_ethereum_erc20_rolling_day.sql

{{ config(
alias ='erc20_rolling_day')
}}

select
'ethereum' as blockchain,
day,
symbol,
current_timestamp() as last_updated,
row_number() over (partition by token_address, wallet_address order by day desc) as recency_index,
sum(amount_raw) over (
) as amount_raw,
sum(amount) over (
) as amount
from {{ ref('transfers_ethereum_erc20_agg_day') }}


transfers_ethereum_schema.yml

  - name: transfers_ethereum_erc20_rolling_hour
meta:
blockchain: ethereum
sector: transfers
project: erc20
contibutors: soispoke, dot2dotseurat
config:
tags: ['transfers', 'ethereum', 'erc20', 'rolling_hour', 'soispoke', 'dot2dotseurat']
columns:
- *blockchain
- *hour