Ali3NAverage Number of Vote Changer Validators Per Proposal (Cosmos, Osmosis Terra)
    Updated 2023-02-22
    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'),

    firstvotes1 as (
    select voter,
    block_timestamp,
    tx_id,
    vote_option,
    proposal_id
    from cosmos.core.fact_governance_votes),

    secondvotes1 as (
    select distinct t1.voter,
    t1.block_timestamp,
    t1.tx_id,
    t1.vote_option,
    t1.proposal_id
    from cosmos.core.fact_governance_votes t1 join firstvotes1 t3 on t1.voter = t3.voter and t1.block_timestamp > t3.block_timestamp and t1.vote_option != t3.vote_option and t1.proposal_id = t3.proposal_id),

    firstvotes2 as (
    select voter,
    block_timestamp,
    tx_id,
    vote_option,
    proposal_id
    from osmosis.core.fact_governance_votes),

    secondvotes2 as (
    select distinct t1.voter,
    t1.block_timestamp,
    t1.tx_id,
    t1.vote_option,
    Run a query to Download Data