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,
vote_option_text,
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'
and left(t1.voter, 38) in (select Account_address from terravalidators)
group by 1,2