with secondary_sales as (
select dayname(to_date(block_timestamp::date)) as week_day,
sum(price_usd) as volume,
count(*) as sales_count
FROM optimism.core.ez_nft_sales
where block_timestamp::date < CURRENT_DATE
and block_timestamp::date >= '{{Start_Date}}'
and EVENT_TYPE = 'sale'
and price_usd > 0
group by week_day
)
select avg(volume) as avg_volume, avg(sales_count), week_day,
case when week_day in ('Sat', 'Sun') then 'WeekEnds'
else 'WeekDays' END as date_type
from secondary_sales
group by week_day order by week_day