SocioCryptooverivew
Updated 2022-12-11
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
›
⌄
SELECT date_trunc('hour',a.block_timestamp) as hour,
CASE WHEN try_parse_json(b.attribute_value):option = '1' then 'Yes'
WHEN try_parse_json(b.attribute_value):option = '2' then 'Abstain'
WHEN try_parse_json(b.attribute_value):option = '3' then 'No'
WHEN try_parse_json(b.attribute_value):option = '4' then 'No With Veto'
END as vote,
COUNT (DISTINCT c.attribute_value) as n_voters,
count(a.tx_id) as n_votes,
sum(n_votes)over(partition by vote ORDER by hour) as cum_n_votes
FROM cosmos.core.fact_msg_attributes a, cosmos.core.fact_msg_attributes b, cosmos.core.fact_msg_attributes c
WHERE a.msg_type = 'proposal_vote' and b.msg_type = 'proposal_vote'
AND a.attribute_key = 'proposal_id' AND a.attribute_value = '82'
AND b.attribute_key = 'option'
AND a.tx_id = b.tx_id
AND a.tx_id = c.tx_id
AND c.msg_type = 'coin_spent' AND c.attribute_key = 'spender'
AND a.tx_succeeded = 'TRUE'
-- AND a.tx_id = 'CFAB67A96F28B60B5517B17A0B978B750B6384557A6AECB3DE4AAB95D5034B63'
GROUP BY hour, vote
having vote is not null
Run a query to Download Data