granadohoNumber of Days LUNA Closed Above and Below $52
    Updated 2022-02-26
    with closed_price as (
    select
    *
    from (
    select
    symbol,
    date(block_timestamp) as date,
    block_timestamp,
    price_usd,
    dense_rank() over ( partition by date order by block_timestamp desc) as index
    from terra.oracle_prices
    where symbol = 'LUNA'
    )
    where index = 1 and EXTRACT(HOUR FROM block_timestamp) = 23 and date >= '2021-11-01'
    order by date
    )

    select
    symbol as currency,
    'Closed above $52' as condition,
    count(distinct date) as number_of_days
    from closed_price
    where price_usd > 52
    group by currency

    union

    select
    symbol as currency,
    'Closed below $52' as condition,
    count(distinct date) as number_of_days
    from closed_price
    where price_usd < 52
    group by currency

    Run a query to Download Data