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

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

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

啊啊啊好长,但是这样的是一步一步想出来的,很清晰详细
select t2.date1 as dt,round(finished/7,2),round(canceled/7,2)
from
(    select date1,count(distinct order_id) finished
    from
    (    select c.order_id,date(b.finish_time) as date1,
        date(c.finish_time) as date2
        from tb_get_car_order b,tb_get_car_order c
        where datediff(b.finish_time,c.finish_time)>=0
        and datediff(b.finish_time,c.finish_time)<=6
        and c.start_time is not null
        order by date1,date2) t1
    where day(date1)=1
    or day(date1)=2
    or day(date1)=3
    group by date1) t2,
(    select date1,count(distinct order_id) as canceled
    from
    (    select c.order_id,date(b.finish_time) as date1,
        date(c.finish_time) as date2
        from tb_get_car_order b,tb_get_car_order c
        where datediff(b.finish_time,c.finish_time)>=0
        and datediff(b.finish_time,c.finish_time)<=6
        and c.start_time is  null
        order by date1,date2) t1
    where day(date1)=1
    or day(date1)=2
    or day(date1)=3
    group by date1) t3
where t2.date1=t3.date1    

全部评论

相关推荐

03-02 08:18
集美大学 Java
钱嘛数字而已:没有赛事奖项么?另外,项目经历字有点多哈,建议突出一下重点:用的什么技术,解决什么问题,达到什么效果。
大家都开始春招面试了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务