DELETE FROM Eap_ColumnSet_User WHERE id IN (SELECT r.eid FROM (SELECT Row_number() OVER( PARTITION BY eSolutionID, eUserId, eField, eIdSearchPlan ORDER BY eSolutionID, eUserId, eField, eIdSearchPlan) AS rankid, * FROM (SELECT e.SolutionID AS eSolutionID, e.UserId AS eUserId, e.Field AS efield, e.IdSearchPlan AS eIdSearchPlan, id AS eid FROM Eap_ColumnSet_User e INNER JOIN (SELECT * FROM (SELECT SolutionID, UserId, Field, IdSearchPlan, Count(*) AS y FROM Eap_ColumnSet_User GROUP BY SolutionID, UserId, Field, IdSearchPlan)a WHERE a.y > 1)b ON b.SolutionID = e.SolutionID AND b.UserId = e.UserId AND b.Field = e.Field AND b.IdSearchPlan = e.IdSearchPlan)h)r WHERE r.rankid > 1)
复制代码
---删除重复栏目方案
DELETE FROM eap_ColumnSetSolution_User WHERE id IN (SELECT r.eid FROM (SELECT Row_number() OVER( PARTITION BY eSolutionID, eUserId, eIdSearchPlan ORDER BY eSolutionID, eUserId, eIdSearchPlan) AS rankid, * FROM (SELECT e.SolutionID AS eSolutionID, e.UserId AS eUserId, e.IdSearchPlan AS eIdSearchPlan, id AS eid FROM eap_ColumnSetSolution_User e INNER JOIN (SELECT * FROM (SELECT SolutionID, UserId, IdSearchPlan, Count(*) AS y FROM eap_ColumnSetSolution_User GROUP BY SolutionID, UserId, IdSearchPlan)a WHERE a.y > 1)b ON b.SolutionID = e.SolutionID AND b.UserId = e.UserId AND b.IdSearchPlan = e.IdSearchPlan)h)r WHERE r.rankid > 1)