EAS 去除重复的 职位 组织树信息_sql

--备份
SELECT * into T_PM_ORGRANGE_bak1110 FROM T_PM_ORGRANGE
--检查是否备份成功
select count(1) from T_PM_ORGRANGE_bak1110
--查询是否有重复脏数据
SELECT FORGID,FUSERID,FTYPE FROM T_PM_ORGRANGE group by FORGID,FUSERID,FTYPE having count(1)>1
--删除脏数据
DELETE FROM T_PM_ORGRANGE WHERE fid not in (SELECT max(Fid) FROM T_PM_ORGRANGE group by FORGID,FUSERID,FTYPE having count(1)>1) and fid in (SELECT t1.fid FROM T_PM_ORGRANGE t1 
inner join (SELECT FORGID,FUSERID,FTYPE FROM T_PM_ORGRANGE group by FORGID,FUSERID,FTYPE having count(1)>1) t2
on t1.FORGID=t2.FORGID
and t1.FUSERID = t2.FUSERID
and t1.FTYPE = t2.FTYPE)