SELECT city, driver_id, ROUND(avgde,1) AS avg_grade, ROUND(cnt/daynum,1) AS avg_order_num, ROUND(mile/daynum,3) AS avg_mileage
FROM(
SELECT city, driver_id, AVG(grade)avgde, COUNT(1)cnt, COUNT(DISTINCT(DATE(order_time)))daynum, SUM(mileage)mile, RANK()over(PARTITION BY city
ORDER BY AVG(grade) DESC)rk
FROM tb_get_car_order a
INNER JOIN tb_get_car_record b USING(uid, order_id)
GROUP BY city, driver_id)t
WHERE rk =1
order by avg_order_num;
每个城市中评分最高的司机信息
最新推荐文章于 2024-09-01 18:06:09 发布