select dt,round(n1/7,2),round(n2/7,2) from (select dt, sum(cn1)over(order by dt rows 6 preceding) n1, sum(cn2)over(order by dt rows 6 preceding) n2 from (select date(order_time) dt,count(start_time) cn1,count(order_time)-count(start_time) cn2 from tb_get_car_order where date(order_time) between date_sub('2021-10-01',interval 6 day) and '2021-10-03' group by dt ) t1 ) t2 where dt between '2021-10-01' and '2021-10-03' order by dt;