maybeyonasTerra Gas stats - Average and Median
    Updated 2021-09-11
    with gas as(
    select
    block_timestamp,
    tx_id,
    fee[0]:amount as amt,
    fee[0]:denom::string as denom,
    gas_used,
    gas_wanted
    from terra.transactions
    ),
    prices as(
    select
    date(block_timestamp) as t_hour,
    currency,
    avg(price_usd) as price_usd
    from terra.oracle_prices
    group by date(block_timestamp),currency
    ),
    txs as(
    select
    block_timestamp,
    tx_id,
    amt,
    denom,
    gas_used,
    gas_wanted,
    price_usd,
    amt*price_usd/pow(10,6) as tx_value
    from gas g join prices p on g.denom=p.currency and date(block_timestamp) = t_hour
    where amt is not null
    ),
    final as(
    select
    block_timestamp,
    tx_id,
    gas_used,
    Run a query to Download Data