MLDZMNGASg18
    Updated 2022-11-16
    with tb1 as (select
    recorded_at::date as day,
    avg (price) as price_token
    from osmosis.core.dim_prices
    where symbol = 'OSMO'
    group by 1),

    tb2 as (select
    sum (amount*price_token) as volume
    from osmosis.core.fact_transfers s join tb1 b on s.block_timestamp::date = b.day
    where block_timestamp >= CURRENT_DATE - 30
    and CURRENCY = 'uosmo')
    select
    volume,
    sum (price_token*split(fee,'uosmo')[0]::numeric/1e6) as amount_gas,
    (1000000*amount_gas)/volume as average_per_one_million
    from osmosis.core.fact_transactions s join tb1 b on s.block_timestamp::Date = b.DAY
    join tb2
    where block_timestamp >= CURRENT_DATE -30
    and TX_STATUS = 'SUCCEEDED'
    and fee ilike '%uosmo%'
    group by 1

    Run a query to Download Data