USE [EnVisage]
GO

WITH FirstRecords (Id, Rn) AS
(
	SELECT Id, 
		ROW_NUMBER() OVER (PARTITION BY [Type], EffectiveDate, SkillId, ResourceId ORDER BY DateCreated ASC) AS rn 
	FROM Skill2Resource
)
DELETE FROM Skill2Resource
WHERE NOT Id IN (SELECT Id FROM FirstRecords WHERE Rn = 1)
GO
