nitsBalance of Staked Addresses
    Updated 2022-03-17
    -- Summarize participation in governance activities by address. What is the distribution of level of governance activity among Terra addresses?
    -- How is this distribution related to how large (in holdings) the addresses are?
    with luna_staked as (
    select
    date,
    address,
    balance_type,
    currency,
    sum(balance) as total_staked_luna
    from terra.daily_balances
    where currency = 'LUNA'
    and balance_type = 'staked'
    and date BETWEEN '2021-07-01' and '2021-10-05'
    group by 1, 2, 3, 4
    order by total_staked_luna desc ),

    powerv_ranking as(
    select
    address,
    case when total_staked_luna < 100 then '< 100'
    when total_staked_luna < 1000 then '< 1000'
    when total_staked_luna < 10000 then '< 10000'
    when total_staked_luna < 100000 then '< 100000'
    when total_staked_luna < 1000000 then '< 1000000'
    when total_staked_luna < 10000000 then '< 10000000'
    when total_staked_luna < 100000000 then '< 100000000'
    else '> 100000000'
    end as staked_luna
    --total_staked_luna as voting_power
    from luna_staked)
    select
    staked_luna,
    count(*) as addresses_in_category
    from powerv_ranking
    group by 1
    order by 1