maybeyonasrune_wealth
    Updated 2021-11-06
    with move_out as (
    select
    from_address,
    -sum(rune_amount) as rune_out
    from thorchain.transfers
    group by 1
    ),
    move_in as (
    select
    to_address,
    sum(rune_amount) as rune_in
    from thorchain.transfers
    group by 1
    ),
    current_bal as (
    select
    from_address,
    case
    when rune_in is null then rune_out
    when rune_out is null then rune_in
    else rune_in+rune_out end as rune_bal
    from move_out full outer join move_in on from_address = to_address
    ),
    group_rune as (
    select *,
    case
    when rune_bal > 1e6 then '7. Million+'
    when rune_bal > 1e5 then '6. 100 Thousand+'
    when rune_bal > 1e4 then '5. 10 Thousand+'
    when rune_bal > 1e3 then '4. Thousand+'
    when rune_bal > 1e2 then '3. Hundred+'
    when rune_bal > 1e1 then '2. Ten+'
    when rune_bal > 1e0 then '1. Dust'
    end as asset_bucket
    from current_bal
    )
    Run a query to Download Data