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

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

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

# 思路:
# 1、将订单表中有取消记录的司机的订单记录提取出来
# 2、计算全体平均数,driver_id设为总体,形成表1
# 3、计算每个司机平均评分,形成表1
# 4、将表1 和表2union连接

select t2.driver_id,round(AVG(t2.grade),1) as avg_grade from (
# 将有取消记录的司机的订单记录提取
select c1.driver_id,c1.grade from tb_get_car_order as c1 
where c1.driver_id in 
(select c2.driver_id from tb_get_car_order as c2 
where c2.start_time is null )) t2 
group by t2.driver_id 
union 
select '总体' as driver_id,round(AVG(t1.grade),1) as avg_grade from (
# 将有取消记录的司机的订单记录提取
select c1.driver_id,c1.grade from tb_get_car_order as c1 
where c1.driver_id in 
(select c2.driver_id from tb_get_car_order as c2 
where c2.start_time is null )) t1 


全部评论

相关推荐

难怪不开摄像头,全是简单的性格题,比大疆友善多了
NULL10086:今早上发的测评,我这还没做呢,官网上已经显示挂了
投递大疆等公司8个岗位
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
06-26 17:24
已编辑
宁波大学 golang
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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