题解 | #国庆期间近7日日均取消订单量#
国庆期间近7日日均取消订单量
https://www.nowcoder.com/practice/2b330aa6cc994ec2a988704a078a0703
select a.dt,
round(count(case when mileage is not null then 1 else null end )/7,2) finish_num_7d,
round(count(case when mileage is null then 1 else null end )/7,2) cancel_num_7d
from
(
select distinct date(order_time) dt
from tb_get_car_order
where start_time >= date('2021-10-01') and start_time < date('2021-10-04')
) a
left join
(
select date(order_time) dt, finish_time,mileage
from tb_get_car_order
) b
on datediff(a.dt, b.dt) between 0 and 6
group by a.dt