考勤档案及历史2099重复数据删除
解决方案:
【适用版本】
8.5及以上版本
【操作步骤】
--备份
select * into attendancefile0307 from T_hr_ats_attendancefile select * into attendancefilehis0307 from T_hr_ats_attendancefilehis
--查询考勤档案的多条重复数据
select * FROM T_hr_ats_attendancefile m where exists ( select fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid from T_hr_ats_attendancefile where m.fproposerid = fproposerid group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1) and fleffdt = {ts '2099-12-31'} and fid not in (select min(fid) from T_hr_ats_attendancefile group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1)
--删除考勤档案的多条重复数据
delete FROM T_hr_ats_attendancefile m where exists ( select fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid from T_hr_ats_attendancefile where m.fproposerid = fproposerid group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1) and fleffdt = {ts '2099-12-31'} and fid not in (select min(fid) from T_hr_ats_attendancefile group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1)
--删除考勤档案历史的多条重复数据
delete FROM T_hr_ats_attendancefilehis m where exists ( select fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid from T_hr_ats_attendancefilehis where m.fproposerid = fproposerid group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1) and fleffdt = {ts '2099-12-31'} and fid not in (select min(fid) from T_hr_ats_attendancefilehis group by fproposerid,feffdt,fleffdt,fadminorgunitid,fpositionid having count(*)>1)
//注意,以上语句请逐条执行
考勤档案及历史2099重复数据删除
本文2024-09-22 21:55:47发表“s-hr cloud知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-shr-123265.html