题解 | #国庆期间近7日日均取消订单量#
select t1.dt, format(sum(if(start_time is not null and finish_time is not null,1,0))/7,2) as finish_num_7d, format(sum(if(start_time is null and finish_time is not null,1,0))/7,2) as cancel_num_7d from ( select '2021-10-01' as dt union select '2021-10-02' as dt union select '2021-10-03' as dt ) t1 join tb_get_car_order t2 on date_format(t2.order_time,'%Y-%m-%d') >= date_sub(t1.dt,interval 6 day) and date_format(t2.order_time,'%Y-%m-%d') <= t1.dt group by t1.dt order by dt