1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| select j.emplid as 员工ID, j.empl_rcd as 员工记录, j.effdt as 生效日期, p.jobcode as 变化前jobcode, j.jobcode as 变化后jobcode, p.deptid as 变化前部门, j.deptid as 变化后部门 from sysadm.ps_job j, sysadm.ps_job p, (select v.emplid, v.empl_rcd, v.effdt, v.effseq, lead(v.effdt) over(partition BY v.emplid, v.empl_rcd ORDER BY v.emplid, v.empl_rcd, v.effdt desc, v.effseq desc) AS pre_effdt, lead(v.effseq) over(partition BY v.emplid, v.empl_rcd ORDER BY v.emplid, v.empl_rcd, v.effdt desc, v.effseq desc) AS pre_effseq from sysadm.ps_job v where v.empl_rcd = 0) a where j.emplid = a.emplid and j.empl_rcd = a.empl_rcd and j.effdt = a.effdt and j.effseq = a.effseq and p.emplid = a.emplid and p.empl_rcd = a.empl_rcd and p.effdt = a.pre_effdt and p.effseq = a.pre_effseq and j.jobcode <> p.jobcode and j.effdt >= TO_DATE('2020-01-01', 'YYYY-MM-DD');
|