select organ_code, organ_name, comm_id, comm_name , date_format(TaskEndTime, '%Y%m') task_ym , sum(case when TaskStatue = 2 then 1 else 0 end) task_finish_num , count(*) task_num from dwd_engine_equipment_inspection_task_d a left join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping) b on a.CommId = b.comm_id group by organ_code, organ_name, comm_id, comm_name , date_format(TaskEndTime, '%Y%m')