select city,
    round(avg(driver_cnt),3) as avg_order_num,
    round(avg(fare_sum),3) as avg_income
from (
    select city,driver_id,
    count(driver_id) as driver_cnt,
    sum(fare) fare_sum
from tb_get_car_record
join tb_get_car_order using (order_id)
where date(order_time) between '2021-10-01' and '2021-10-07'and city='北京'
group by driver_id
having count(driver_id)>=3
    ) df
group by city