删除(多字段)重复记录
一、删除(多字段)重复记录
IF (SELECT object_ID('tempdb.dbo.#Test'))>0 DROP TABLE #Test
SELECT IDENTITY (INT,1, 1) AS FID, JobID,FlashTime
INTO #Test
FROM HFlashCardRecord
WHERE FlashTime between '2004-11-16' and '2004-11-18'
ORDER BY Cast(JobID as NUMERIC(18,0)),FlashTime
DELETE FROM #Test WHERE FID IN(
SELECT MAX(FID) FROM #Test
GROUP BY FlashTime, JobID HAVING COUNT(FID)>1
)
SELECT * FROM #Test