LTirrell18. Wealth distribution
    Updated 2021-11-16
    -- 18. What is the distribution of wealth within the THORChain ecosystem? Show a histogram of the breakdown


    with to_addresses as (
    select
    to_address as address,
    sum(rune_amount) as amount
    from
    thorchain.transfers
    where block_timestamp::date>current_date-30
    group by
    to_address
    ),
    from_addresses as (
    select
    from_address as address,
    sum(rune_amount) as amount
    from
    thorchain.transfers
    where block_timestamp::date>current_date-30
    group by
    from_address
    )
    select
    t.address as address,
    t.amount as rune_in,
    f.amount as rune_out,
    t.amount - f.amount as total
    from
    to_addresses t
    inner join from_addresses f on t.address = f.address
    order by
    4

    Run a query to Download Data