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

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

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

select 
    city   city
    ,driver_id  driver_id
    ,round(avg(grade),1)   avg_grade
    ,round(count(driver_id)/count(distinct substring(order_time,1,10)),1) avg_order_num
    ,round(sum(mileage)/count(distinct substring(order_time,1,10)),3) avg_mileage
from 
    tb_get_car_order t2
left join 
    tb_get_car_record t3 
on 
    t2.order_id=t3.order_id 
where 
    driver_id 
in 
    (select 
    driver_id 
from
(
select 
    city
    ,driver_id
    ,avg_grade 
    ,dense_rank()over(partition by city order by avg_grade desc) rk
from 
(
select
     city
    ,driver_id
    ,avg(grade) avg_grade
from 
    tb_get_car_order t4
left join 
    tb_get_car_record t5 
on 
    t4.order_id=t5.order_id
group by 
    city
    ,driver_id
) t0   
) t1 
where 
    rk=1 )
group by 
    city
    ,driver_id
order by 
    avg_order_num

全部评论

相关推荐

AFBUFYGRFHJLP:直接去美帝试试看全奖phd吧
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-26 15:46
已编辑
字节国际 电商后端 24k-35k
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务