SELECT he.name as 姓名, count(cou.num) as 差错, cou.pp, cou.ooti FROM OMS_OE_ORDER_TYPES_REPORT T , oms_oe_order_types tt, hr_employee he, sys_user su, (select distinct olr.remain_no as num, to_char(res.PZ_DATE,'yyyy-mm') as pp, olr.order_type_id as ooti from OMS_LO_REMAIN olr, OMS_LO_RESPONSIBLE res, sys_user su where res.CREATED_BY=olr.CREATED_BY and olr.created_by=su.employee_id and olr.TYPES='遗留单' and olr.REMAIN_KIND=1 and olr.remain_no is not null and olr.status<>9 ${if(len(BookDates)=0,"and res.high_version='Y'","and res.START_DATE>=to_date('"+BookDates+"','yyyy-mm-dd') and res.high_version='Y'")} ${if(len(BookDatee)=0,"and res.high_version='Y'","and res.START_DATE<=to_date('"+BookDatee+"','yyyy-mm-dd') and res.high_version='Y'")} ${if(len(BookDates_c)=0,"","and res.PZ_DATE>=to_date('"+BookDates_c+"','yyyy-mm-dd')")} ${if(len(BookDates_c)=0,"","and res.PZ_DATE<=to_date('"+BookDatee_c+"','yyyy-mm-dd')")} group by to_char(res.PZ_DATE,'yyyy-mm'), olr.remain_no, olr.order_type_id )as cou where tt.order_type_id=t.order_type_id and t.order_type_id=cou.ooti --and t.order_type_id =olr.order_type_id --and res.CREATED_BY=olr.CREATED_BY --and olr.created_by=su.employee_id and he.EMPLOYEE_ID=su.EMPLOYEE_ID and T.PA_UNIT_CODE=${tp} AND tt.left_flag='Y' ${if(len(xm) == 0,"","and he.name = '"+xm+"'")} group by he.name ,cou.pp,cou.ooti |