Eman-RazTop 10 Addresses that have Collected the Largest Amount of ATOM
    Updated 2023-02-21
    with table1 as (
    with tab1 as (select sender as "Address", sum(amount)/pow(10,6) as volume_out
    from cosmos.core.fact_transfers
    where tx_succeeded='TRUE' and block_timestamp::date>='2023-01-01'
    and currency='uatom'
    group by 1
    order by 1),

    tab2 as (select receiver as "Address", sum(amount)/pow(10,6) as volume_in
    from cosmos.core.fact_transfers
    where tx_succeeded='TRUE' and block_timestamp::date>='2023-01-01'
    and currency='uatom'
    group by 1
    order by 1)

    select tab1."Address" as "Address", volume_out, volume_in, case
    when volume_out is null then 0
    else volume_out
    end as "Volume Out", case
    when volume_in is null then 0
    else volume_in
    end as "Volume In"
    from tab1 left join tab2 on tab1."Address"=tab2."Address")

    select "Address", -"Volume Out" as "Volume Out", "Volume In", "Volume In"-"Volume Out" as "Net Volume"
    from table1
    order by 4 desc
    limit 10


    Run a query to Download Data