select
    c.organ_code
     , c.organ_name
     , c.comm_id
     , c.comm_name
     , concat(left(`time`,4), lpad(week(`time`,3),'2','0')) yw
     , sum(carflow) carflow
     , sum(flowOutNum) flowOutNum
     , sum(manualNum) manualNum
     , sum(remoteNum) remoteNum
     , sum(remoteOutNum) remoteOutNum
     , sum(manualOutNum) manualOutNum
     , sum(manualOutNum)/ nullif(sum(carflow),0) exceptionRate
from dwd_engine_stat_exception_rate_d a
         left join dim_tongtong_carpark_d b
                   on a.parkcode = b.parkcode
         left join dim_organ_mapping c
                   on b.parkID = c.tongtong_park_id
where c.comm_id is not null
group by
    c.organ_code
       , c.organ_name
       , c.comm_id
       , c.comm_name
       , concat(left(`time`,4), lpad(week(`time`,3),'2','0'))