with pricet as (
select
timestamp::date as day,
avg(price_usd) as near_price_usd
from near.core.fact_prices
where symbol = 'wNEAR'
group by day
order by day asc
)
select
day,
count(distinct tx_hash) as txn_count,
near_price_usd,
avg (near_price_usd) over (order by day rows between 6 preceding and current row) as moving_average_7_days
from near.core.fact_transactions
join pricet
on block_timestamp::date = day
where tx_status = 'Success'
group by 1, 3
order by 1