bachiosmo362-7
    Updated 2022-11-24
    with firstvotes as (
    select voter,
    min (block_timestamp) as minvote1
    from osmosis.core.fact_governance_votes
    where proposal_id in ('362')
    and tx_status = 'SUCCEEDED'
    group by 1),

    firstvote1 as (
    select t1.voter,
    minvote1,
    vote_option
    from osmosis.core.fact_governance_votes t1 join firstvotes t2 on t1.voter = t2.voter and t1.block_timestamp = t2.minvote1
    where proposal_id in ('362')
    and tx_status = 'SUCCEEDED'),

    secondvotes as (
    select distinct t1.voter,
    t1.block_timestamp,
    t1.tx_id,
    t2.vote_option
    from osmosis.core.fact_governance_votes t1 join firstvote1 t2 on t1.voter = t2.voter and t1.block_timestamp > t2.minvote1 and t1.vote_option != t2.vote_option
    where proposal_id in ('362')
    and tx_status = 'SUCCEEDED'),

    table1 as (
    select t1.voter,
    count (distinct t1.tx_id) as votes_count
    from secondvotes t1
    group by 1 having votes_count > 1)

    select address, avg (balance/pow(10,decimal)) as OSMO_Balance
    from osmosis.core.fact_daily_balances
    where currency = 'uosmo'
    and date = (select max(date) from osmosis.core.fact_daily_balances)
    and address in (select voter from table1)
    Run a query to Download Data