John_GaltRCT Price, one minute intervals
    Updated 2022-05-06
    with table1 as (select
    block_timestamp as date,
    event_attributes:ask_asset as ask,
    event_attributes:offer_amount as offer,
    event_attributes:return_amount as returnn,
    case
    when ask = 'terra17n223dxpkypc5c48la7aqjvverczg82ga3cr93' then offer
    else 0
    end as ust_to_buy_neb,
    case
    when ask = 'terra17n223dxpkypc5c48la7aqjvverczg82ga3cr93' then returnn
    else 0
    end as bought_neb,
    case
    when ask = 'uusd' then offer
    else 0
    end as ust_to_sell_neb,
    case
    when ask = 'uusd' then returnn
    else 0
    end as sold_neb,
    case
    when ust_to_buy_neb > 0 then ust_to_buy_neb / nullif(bought_neb, 0)
    when ust_to_buy_neb = null then ust_to_sell_neb / nullif(sold_neb, 0)
    end as neb_price
    from terra.msg_events
    where date(block_timestamp) > '2022-04-24'
    and (event_attributes:ask_asset = 'terra17n223dxpkypc5c48la7aqjvverczg82ga3cr93' or event_attributes:ask_asset = 'uusd')
    and (event_attributes:"0_contract_address" = 'terra1mxd85ljdjcm7ddfh8qvnxx8tyggnh3zsahy7aa'
    or event_attributes:"1_contract_address" = 'terra1mxd85ljdjcm7ddfh8qvnxx8tyggnh3zsahy7aa')
    and event_index = 3
    ),

    table2 as (select date, neb_price
    from table1
    ),
    Run a query to Download Data