Eman-Raz$FDUSD Holders on Ethereum (Sorted by Balance)
    Updated 2024-01-16
    with tab4 as (with tab3 as (with tab1 as (select to_address, sum(amount) as input_vol
    from ethereum.core.ez_token_transfers
    where contract_address=lower('0xc5f0f7b66764f6ec8c8dff7ba683102295e16409')
    group by 1),

    tab2 as (select from_address, sum(amount) as output_vol
    from ethereum.core.ez_token_transfers
    where contract_address=lower('0xc5f0f7b66764f6ec8c8dff7ba683102295e16409')
    group by 1)

    select to_address as address, case
    when input_vol is null then 0 else input_vol end as input_volume, case
    when output_vol is null then 0 else output_vol end as output_volume
    from tab1 left join tab2 on tab1.to_address=tab2.from_address)

    select address, input_volume AS "📥Input Volume", output_volume AS "📤Output Volume",
    input_volume-output_volume as "🔴Balance"
    from tab3
    ORDER BY 4 DESC),

    tab5 as (select address, ADDRESS_name
    from ethereum.core.dim_labels)

    select tab4.address as "💼Address", address_name as "📃Address Name", "📥Input Volume", "📤Output Volume", "🔴Balance"
    from tab4 left join tab5 on tab4.address=tab5.address
    order by 5 desc
    QueryRunArchived: QueryRun has been archived