#目标司机 with a as (select distinct driver_id from tb_get_car_order where mileage is null and date_format(order_time,'%Y%m')='202110') select ifnull(driver_id,'总体'),round(avg(grade),1) as avg_grade from tb_get_car_order where driver_id in (select driver_id from a) and grade is not null group by driver_id with rollup
三刷 with rollup 之前不能加order by