select city,
round(avg(cnt),3) avg_order_num,
round(avg(total_fare),3) avg_income
from (select driver_id,
city,
count(a.order_id) cnt,
sum(fare) total_fare
from tb_get_car_order a
left join tb_get_car_record b
on a.order_id = b.order_id
where city = '北京'
and (date(order_time) BETWEEN '2021-10-01' and '2021-10-07')
GROUP BY driver_id
having cnt>=3
) a