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

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

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

with t as(
    select driver_id, grade
    from tb_get_car_order
    where driver_id in (select driver_id from tb_get_car_order where fare is null and date_format(order_time, '%Y-%m') = '2021-10') and grade is not null
)

select driver_id, round(avg_grade, 1) avg_grade
from (select driver_id, avg(grade) avg_grade
from t
group by driver_id
union
    select '总体' driver_id, avg(grade) avg_grade
    from t
) t2 

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务