select
(sum(gas_used/pow(10,9)) * avg(price))/(((sum(amount/pow(10,6)))*avg(price))/1000000)
from osmosis.core.fact_transfers t
inner join osmosis.core.fact_transactions ft on t.tx_id = ft.tx_id
inner join osmosis.core.dim_prices p on RECORDED_AT::date = ft.block_timestamp::date and hour(p.RECORDED_AT) = hour(ft.block_timestamp)
where ft.block_timestamp > CURRENT_DATE - 31
and ft.tx_status = 'SUCCEEDED'
and symbol = 'OSMO'
and currency = 'uosmo'