我正在使用PeopleSoft的查询管理器来构建一个新的雇佣报告,该报告会引入经理的姓名。不幸的是,Job-EE表将报告记录到位置而不是经理。为了获得管理员的名字,我必须再次链接到Job-EE表,将两个表与A.Reports_To链接起来等于G.Position_NBR。所以现在我有两个Job-EE表的视图。问题是我正在查看日期范围(2018年1月1日到现在),我无法弄清楚如何在雇用日期的同时引入经理。我似乎带来了在结束生效日期之前一直处于Reports_To职位的所有经理。我认为这是因为Job-EE表链接到位置(报告)而不是实际员工。占据报告的人经常变化。
有人有什么建议吗? 编辑更新:以下是各种表格,查询管理器标准等的一些图片:
这是SQL:
SELECT DISTINCT A.EMPLID, B.NAME, (CONVERT(CHAR(10),A.EFFDT,121)), A.DEPTID, D.DESCR, C.DESCR, A.ANNUAL_RT, E.DESCR, G.EMPLID, G.POSITION_NBR, Concat( H.FIRST_NAME,' ', H.LAST_NAME)
FROM PS_JOB A, PS_EMPLMT_SRCH_QRY A1, PS_PERSONAL_DATA B, PS_DEPT_TBL D, PS_SET_CNTRL_REC D2, PS_JOBCODE_TBL C, PS_SET_CNTRL_REC C2, PS_LOCATION_TBL E, PS_SET_CNTRL_REC E2, PS_JOB G, PS_EMPLMT_SRCH_QRY G1, PS_NAMES H, PS_PERALL_SEC_QRY H1
WHERE ( D.DEPTID = A.DEPTID
AND D2.SETCNTRLVALUE = A.BUSINESS_UNIT
AND D2.RECNAME = 'DEPT_TBL'
AND D2.SETID = D.SETID
AND C.JOBCODE = A.JOBCODE
AND C2.SETCNTRLVALUE = A.BUSINESS_UNIT
AND C2.RECNAME = 'JOBCODE_TBL'
AND C2.SETID = C.SETID
AND E.LOCATION = A.LOCATION
AND E2.SETCNTRLVALUE = A.BUSINESS_UNIT
AND E2.RECNAME = 'LOCATION_TBL'
AND E2.SETID = E.SETID
AND A.EMPLID = A1.EMPLID
AND A.EMPL_RCD = A1.EMPL_RCD
AND A1.OPRID = 'XXXXXXXX'
AND G.EMPLID = G1.EMPLID
AND G.EMPL_RCD = G1.EMPL_RCD
AND G1.OPRID = 'XXXXXXXX'
AND H.EMPLID = H1.EMPLID
AND H1.OPRID = 'XXXXXXXX'
AND ( A.EFFDT = (SELECT MIN( F.EFFDT)
FROM PS_JOB F, PS_EMPLMT_SRCH_QRY F1
WHERE F.EMPLID = F1.EMPLID
AND F.EMPL_RCD = F1.EMPL_RCD
AND F1.OPRID = 'XXXXXXXX'
AND ( A.EMPLID = F.EMPLID
AND A.EMPL_RCD = F.EMPL_RCD
AND A.ACTION IN ('HIR','REH','REI')
AND A.EFFDT BETWEEN :1 AND :2 ))
AND A.ACTION IN ('HIR','REH','REI')
AND B.EMPLID = A.EMPLID
AND D.EFFDT =
(SELECT MAX(D_ED.EFFDT) FROM PS_DEPT_TBL D_ED
WHERE D.SETID = D_ED.SETID
AND D.DEPTID = D_ED.DEPTID
AND D_ED.EFFDT <= A.EFFDT)
AND C.EFFDT =
(SELECT MAX(C_ED.EFFDT) FROM PS_JOBCODE_TBL C_ED
WHERE C.SETID = C_ED.SETID
AND C.JOBCODE = C_ED.JOBCODE
AND C_ED.EFFDT <= A.EFFDT)
AND E.EFFDT =
(SELECT MAX(E_ED.EFFDT) FROM PS_LOCATION_TBL E_ED
WHERE E.SETID = E_ED.SETID
AND E.LOCATION = E_ED.LOCATION
AND E_ED.EFFDT <= A.EFFDT)
AND A.REPORTS_TO = G.POSITION_NBR
AND G.EMPLID = H.EMPLID
AND H.EFFDT =
(SELECT MAX(H_ED.EFFDT) FROM PS_NAMES H_ED
WHERE H.EMPLID = H_ED.EMPLID
AND H.NAME_TYPE = H_ED.NAME_TYPE)
AND G.EFFDT =
(SELECT MAX(G_ED.EFFDT) FROM PS_JOB G_ED
WHERE G.EMPLID = G_ED.EMPLID
AND G.EMPL_RCD = G_ED.EMPL_RCD
AND G_ED.EFFDT <= ( A.LAST_HIRE_DT)+1)
AND G.EFFSEQ =
(SELECT MAX(G_ES.EFFSEQ) FROM PS_JOB G_ES
WHERE G.EMPLID = G_ES.EMPLID
AND G.EMPL_RCD = G_ES.EMPL_RCD
AND G.EFFDT = G_ES.EFFDT) ))
除此之外如果您的机构/公司只使用SUPERVISOR_ID字段会更容易,那么您的问题似乎是:
我似乎带来了在结束生效日期之前一直处于Reports_To职位的所有经理
这是因为,在初始选择PS_JOB(A)时,您只将生效日期(EFFDT)限制为输入范围[:1,:2],以便记录动作为('HIR','REH',' REI“)。
AND ( A.EFFDT BETWEEN :1 AND :2
AND A.ACTION IN ('HIR','REH','REI')
... )
这将选择区间中具有EFFDT的每个记录,而您只需要一个,大概是第一个(MIN)。
AND ( A.EFFDT = (SELECT MIN(A_ED.EFFDT) FROM PS_JOB A_ED
WHERE A_ED.EMPLID = A.EMPLID
AND A_ED.EMPL_RCD = A.EMPL_RCD
AND A.ED.EFFDT BETWEEN :1 AND :2
AND A_ED.ACTION IN ('HIR', 'REH', 'REI')
... )
这可能会解决问题,但请记住,您可能还需要考虑有效序列(EFFSEQ)来过滤掉一条记录。
编辑:通过查询管理器