nitsAverage and Median Voting Power (for Yes)
    Updated 2022-04-25
    with all_proposals as
    (SELECT proposal_id, count(DISTINCT voter) as total_voters_per_proposal from terra.gov_vote
    GROUP by 1) ,
    yes_proposals AS
    ((SELECT proposal_id as pid , count(DISTINCT voter) as total_yes_voters_per_proposal from terra.gov_vote
    where OPTION = 'VOTE_OPTION_YES'
    GROUP by 1) ),
    balance as (
    SELECT * from terra.daily_balances
    where currency = 'LUNA' and balance_type = 'staked' )

    SELECT avg(total_voting_power) as avg_voting_power, median (total_voting_power) as median_voting_power from
    (SELECT proposal_id, sum(voting_power) as total_voting_power from terra.gov_vote
    where voting_power is not NULL and contains(option, 'YES')
    GROUP by 1 )
    LIMIT 100
    Run a query to Download Data