题解 | 国庆期间近7日日均取消订单量
with a as (
SELECT
date( order_time ) dt,
count( start_time ) cn,
count( 1 ) - count( start_time ) cc
FROM
tb_get_car_order
GROUP BY
date( order_time ))
select a.dt,round(sum(b.cn)/7,2),round(sum(b.cc)/7,2)
from a left join a b
on datediff(a.dt,b.dt) between 0 and 6
where a.dt between '2021-10-01' and '2021-10-03'
group by a.dt;