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
*
from closed_price