with tb1 as
(
select
tx_id,
attribute_value as proposal_ids
from
cosmos.core.fact_msg_attributes
where
msg_type ilike '%proposal_vote%'
and attribute_key = 'proposal_id'
and tx_succeeded = 'TRUE'
)
,
tb2 as
(
select
t1.block_timestamp,
t1.tx_id,
proposal_ids,
t1.attribute_value as voter
from
cosmos.core.fact_msg_attributes t1
left join
tb1 t2
on t1.tx_id = t2.tx_id
where
t1.tx_id in
(
select
tx_id
from
tb1
)
and t1.msg_type = 'message'
and t1.tx_succeeded = 'TRUE'
and t1.attribute_key = 'sender'