with A as(
select
distinct voter as voter
from osmosis.core.fact_governance_votes
where TX_STATUS = 'SUCCEEDED'
and PROPOSAL_ID = '362'),
B as(
select
address,
sum(balance/pow(10,6)) as balance
from osmosis.core.fact_daily_balances
where CURRENCY = 'uosmo'
and BALANCE_TYPE = 'staked'
and date >= '2022-11-14' and date <= '2022-11-19'
and address in (select voter from A)
group by 1)
select
avg(balance)
from B