alleriaVotes, Votes, Votes
    Updated 2022-04-22
    WITH
    latest_tx as (
    SELECT
    voter as label,
    proposal_id,
    max(block_timestamp) as latest_timestamp
    FROM terra.gov_vote
    GROUP BY voter, proposal_id
    ORDER BY proposal_id DESC
    ),

    test as (
    SELECT
    a.proposal_id,
    voter_label_subtype,
    CASE
    WHEN voter_label_subtype = 'validator' THEN voter_label_subtype
    WHEN voter_label_subtype is NULL THEN 'retail'
    ELSE 'contract_deployer'
    END as category,
    SUM(voting_power) as total_voting_power
    FROM terra.gov_vote a
    INNER JOIN latest_tx ON (a.proposal_id = latest_tx.proposal_id AND a.block_timestamp = latest_timestamp)
    WHERE (option = 'VOTE_OPTION_YES' OR option = 'YES')
    --AND voter_label_subtype != 'contract_deployer'
    GROUP BY a.proposal_id, voter_label_subtype
    ORDER BY a.proposal_id ASC
    )

    SELECT
    *
    FROM terra.gov_vote
    WHERE proposal_id = '971'

    Run a query to Download Data