题解 | #2021年国庆在北京接单3次及以上的司机统计信息#
2021年国庆在北京接单3次及以上的司机统计信息
http://www.nowcoder.com/practice/992783fd80f746d49e790d33ee537c19
select
M.city,
round(avg(num), 3),
round(avg(fare), 3)
from
(
select
tg.city,
count(tr.order_id) num,
sum(tr.fare) fare
from
tb_get_car_record tg
inner join tb_get_car_order tr on tg.order_id = tr.order_id
where
tg.order_id > 0
and tg.city = '北京'
and date_format(tr.order_time, "%Y-%m-%d") >= '2021-10-01'
and date_format(tr.order_time, "%Y-%m-%d") <= '2021-10-07'
group by
tr.driver_id
having
num > 2
) M
group by
M.city