LTirrell2022-02-25_terra_52-pickup
    Updated 2022-03-01
    with price as (
    select
    date_trunc('day', block_timestamp) as datetime,
    avg(price_usd) as daily_avg_price,
    min(price_usd) as daily_min_price,
    max(price_usd) as daily_max_price
    from
    terra.oracle_prices
    where
    symbol = 'LUNA'
    and datetime >= '2021-09-30'
    group by
    datetime
    order by
    datetime asc
    ),
    above_value as (
    select
    datetime,
    case
    when daily_avg_price >= 52 then 1
    else 0
    end as avg_above,
    case
    when daily_min_price >= 52 then 1
    else 0
    end as min_above,
    case
    when daily_max_price >= 52 then 1
    else 0
    end as max_above
    from
    price
    )
    select
    price.datetime,
    Run a query to Download Data