Ali3NDistribution of Voters By Their Type (Validator or Non-Validator) (Terra Recent 5)
    Updated 2023-01-21
    with terravalidators as (
    select REPLACE(ATTRIBUTE_VALUE, 'valoper', '') as validator_address1,
    left(validator_address1, 38) as Account_address
    from terra.core.fact_msg_attributes
    where ATTRIBUTE_KEY= 'source_validator'
    and tx_succeeded = 'TRUE')

    select 'Proposal #' || proposal_id,
    case when left(t1.voter, 38) in (select Account_address from terravalidators) then 'Validator'
    else 'Non-Validator' end as voter_type,
    count (distinct tx_id) as Votes_Count,
    count (distinct voter) as Voters_count
    from terra.core.fact_governance_votes t1
    where proposal_id in ('3796','3795','3794','3665','3619')
    and tx_succeeded = 'TRUE'
    group by 1,2

    Run a query to Download Data