题解 | #国庆期间近7日日均取消订单量#

国庆期间近7日日均取消订单量

https://www.nowcoder.com/practice/2b330aa6cc994ec2a988704a078a0703

-- 请统计国庆头3天里,每天的近7日日均订单完成量和日均订单取消量,按日期升序排序。结果保留2位小数。
with t1 as (select date(order_time) dt,sum(case when start_time is not null then 1 else 0 end) finish_num,sum(case when start_time is null then 1 else 0 end) cancel_num
from tb_get_car_record a 
left join 
tb_get_car_order b 
on a.uid = b.uid 
and a.order_id = b.order_id
where date(order_time) between '2021-09-25' and '2021-10-03'
group by date(order_time)),
t2 as (select dt,date_add(dt,interval -6 day) dt_curr from t1
where dt between '2021-10-01' and '2021-10-03')
select t2.dt,round(sum(finish_num)/7,2) finish_num_7d,
round(sum(cancel_num)/7,2) cancel_num_7d
from t1,t2
where datediff(t2.dt,t1.dt) between 0 and 6
group by t2.dt
order by t2.dt ASC

全部评论

相关推荐

预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
点赞 评论 收藏
分享
牛客263158796号:我领羊一面后十天不挂也不推进 今天问hr说等前序的第一批意向发完看情况再看是否推进
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务