Tony_IntelUSDC holders of L2s vs Avalanche
    Updated 2023-06-22
    select count(distinct address) as USDC_holders, date, 'Arbitrum' as blockchain
    from (
    select sum(amount) over (partition by address order by date) as holded_USDC, address, date
    from (
    select sum(-raw_amount/pow(10, 6)) as amount, from_address as address, date_trunc('week', block_timestamp) as date
    from arbitrum.core.fact_token_transfers
    where contract_address in (lower('0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'), lower('0xaf88d065e77c8cC2239327C5EDb3A432268e5831'))
    group by 2, 3
    union all
    select sum(raw_amount/pow(10, 6)) as amount, to_address as address, date_trunc('week', block_timestamp) as date
    from arbitrum.core.fact_token_transfers
    where contract_address in (lower('0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'), lower('0xaf88d065e77c8cC2239327C5EDb3A432268e5831'))
    group by 2, 3
    )
    )
    where holded_USDC > 0
    and date::date >= '2022-04-11'
    group by 2
    union all

    select count(distinct address) as USDC_holders, date, 'Avalanche' as blockchain
    from (
    select sum(amount) over (partition by address order by date) as holded_USDC, address, date
    from (
    select sum(-raw_amount/pow(10, 6)) as amount, from_address as address, date_trunc('week', block_timestamp) as date
    from avalanche.core.fact_token_transfers
    where contract_address in (lower('0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664'), lower('0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'))
    group by 2, 3
    union all
    select sum(raw_amount/pow(10, 6)) as amount, to_address as address, date_trunc('week', block_timestamp) as date
    from avalanche.core.fact_token_transfers
    where contract_address in (lower('0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664'), lower('0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'))
    group by 2, 3
    )
    )
    where holded_USDC > 0
    Run a query to Download Data