SELECT SFC, MIN(CreateOn) AS MINCreateOn
INTO #Duplicates
FROM MANU_EXECUTION
WHERE WorkOrderId='A49583FF-1EBB-11EE-A0F8-005056BF5922'
GROUP BY SFC
HAVING COUNT(SFC) > 1;
UPDATE MANU_EXECUTION SET IsDeleted=1, UpdateBy='ZJJ', IsOffline='1' WHERE Id in (
SELECT e.Id FROM MANU_EXECUTION e INNER JOIN #Duplicates AS d ON e.SFC=d.SFC AND e.CreateOn=d.MINCreateOn)
DROP TABLE #Duplicates;
标签:MANU,删除,CreateOn,重复,玩法,Id,Duplicates,SFC,SELECT From: https://www.cnblogs.com/oocn/p/17623923.html