我需要消除NIC Number重复的情况。请为我提供SQL查询。
答案 0 :(得分:1)
DELETE FROM Table_Name A
INNER JOIN (SELECT NIC, COUNT(*) AS RecCount, MIN(RESULT) AS OlderValue
FROM Table_Name
GROUP BY NIC) b
ON A.NIC = b.NIC
AND a.RESULT != b.OlderValue
答案 1 :(得分:0)
WHILE EXISTS (SELECT NIC FROM TABLE_NAME
HAVING COUNT(NIC) > 1)
DELETE TOP 1 FROM TABLE_NAME WHERE NIC IN (SELECT NIC FROM TABLE_NAME HAVING COUNT(NIC) > 1) ORDER BY SubjectID DESC