题解 | #每个城市中评分最高的司机信息#

每个城市中评分最高的司机信息

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


with t1 as(
select t1.city,t2.driver_id,avg(grade) as avg from tb_get_car_record t1 join tb_get_car_order t2 on t1.uid=t2.uid and t1.order_id=t2.order_id
where t2.grade is not null
group by t1.city,t2.driver_id
order by avg desc),

t2 as(
select *,rank()over(partition by city order by avg desc) as rk from t1),

t3 as(
select * from t2 where rk =1)


select t3.city,t4.driver_id,
round(avg(t4.grade),1) as avg_grade,
round(count(t4.order_id)/count(distinct date(t4.order_time)),1) as avg_order_num,
round(sum(mileage)/count(distinct date(t4.order_time)),3) as avg_mileage
from tb_get_car_order t4 join t3 on t4.driver_id=t3.driver_id
group by t4.driver_id,t3.city
order by avg_order_num

全部评论

相关推荐

找到实习了 给了150一天 但是说是低代码 值得去吗
码农索隆:是在没实习,可去,待个一两周,不行就润呗
点赞 评论 收藏
分享
程序员牛肉:这一眼假啊,基本上都是骗人的,不然就涉及到职位贪腐了,就像之前华为的OD事件,看你运气好不好了
点赞 评论 收藏
分享
流浪的神仙:无恶意,算法一般好像都得9硕才能干算法太卷啦
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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