MLDZMNOGB13
    Updated 2022-11-24
    with tb1 as (select
    voter,
    block_timestamp,
    tx_id,
    Description
    from osmosis.core.fact_governance_votes a
    left join osmosis.core.dim_vote_options b on a.vote_option = b.vote_id
    where proposal_id ='362'
    and tx_status = 'SUCCEEDED'),

    tb2 as (select
    distinct a.voter,
    a.block_timestamp,
    a.tx_id,
    b.Description
    from osmosis.core.fact_governance_votes a left join osmosis.core.dim_vote_options b on a.vote_option = b.vote_id
    join tb1 c on a.voter = c.voter and b.description <> c.description and a.block_timestamp > c.block_timestamp
    where proposal_id ='362'
    and tx_status = 'SUCCEEDED'),

    tb3 as (select
    *
    from osmosis.core.fact_governance_votes a left join osmosis.core.dim_vote_options b on a.vote_option = b.vote_id
    where tx_status = 'SUCCEEDED'
    and proposal_id ='362')

    select
    case
    when address in (select voter from tb2) then 'Switch Vote'
    else 'Remain as same Vote' end as gp,
    avg (balance/pow(10,6)) as balance_osmo
    from osmosis.core.fact_daily_balances
    where currency = 'uosmo'
    and date = CURRENT_DATE-2
    and address in(select voter from tb3)
    group by 1
    Run a query to Download Data