题解 | #有取消订单记录的司机平均评分#

有取消订单记录的司机平均评分

https://www.nowcoder.com/practice/f022c9ec81044d4bb7e0711ab794531a

-- 看问题
with t1 as (select distinct driver_id from tb_get_car_order
where mileage is null
and date(finish_time) between '2021-10-01' and '2021-10-31'
),
t2 as (select driver_id,grade
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 grade is not null
and start_time is not null 
)
select t1.driver_id,round(avg(grade),1) avg_grade
from t1
left join t2 
on t1.driver_id = t2.driver_id
group by driver_id
union 
select '总体' driver_id,round(avg(grade),1) avg_grade
from t1
left join t2 
on t1.driver_id = t2.driver_id

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-27 10:46
点赞 评论 收藏
分享
点赞 评论 收藏
分享
一颗宏心:华为HR晚上过了十二点后还给我法消息。
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务