我这sql哪里有问题

image.png

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

FineReport 帆软用户XpbwOTiAvi 发布于 2022-6-8 11:08 (编辑于 2022-6-8 11:13)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
重庆一棵草Lv4中级互助
发布于2022-6-8 11:12

image.png

  • 2关注人数
  • 285浏览人数
  • 最后回答于:2022-6-8 11:13
    请选择关闭问题的原因
    确定 取消
    返回顶部