Updated 2022-11-29
    with tab1 as (select date_trunc( 'week',block_timestamp) as week, event_data:to as wallet,
    sum(event_data:amount) as in_amount
    from flow.core.fact_events
    where event_contract = 'A.1654653399040a61.FlowToken' and event_type ilike '%Deposited' and tx_succeeded ilike 'TRUE'
    group by 1,2),
    tab2 as (select date_trunc( 'week',block_timestamp) as week, event_data:from as wallet,
    sum(event_data:amount) as out_amount
    from flow.core.fact_events
    where event_contract = 'A.1654653399040a61.FlowToken' and event_type ilike '%Withdrawn' and tx_succeeded ilike 'TRUE'
    group by 1,2),
    tab3 as (select tab1.week, tab1.wallet, in_amount, out_amount, in_amount-out_amount as balance
    from tab1 join tab2 on tab1.week=tab2.week and tab1.wallet = tab2.wallet
    where tab1.wallet != 'null')
    select week, count(distinct wallet) as number_FLOW_wallets,
    sum(balance) as total_FLOW_balance
    from tab3 where balance >0 and week >= '2022-01-01' and week <= current_date - 1
    group by 1
    Run a query to Download Data