with
tx as (
SELECT TX_FROM as wallet, min(BLOCK_TIMESTAMP) as first_tx
FROM osmosis.core.fact_transactions where TX_STATUS = 'SUCCEEDED' GROUP by 1),
voting as(SELECT VOTER, min(BLOCK_TIMESTAMP) as first_vote
from osmosis.core.fact_governance_votes where TX_STATUS = 'SUCCEEDED' GROUP by 1),
middle as (
SELECT wallet, first_tx, first_vote , datediff(hour, first_tx, first_vote) as waiting_time
from tx join voting on voting.voter = tx.wallet)
SELECT avg(waiting_time) as average_waiting_time from middle