You can simply delete not wanted RwNum(s).
DELETE
FROM #Final
WHERE RwNum IN (
SELECT IIF(a.RwNum > b.RwNum, a.RwNum , b.RwNum)
FROM #Final a
JOIN #Final b
ON ( a.JobSource = b.JobSource AND a.RuleName = b.RuleName )
OR ( a.JobSource = b.JobSource AND a.PackageType = b.PackageType AND a.RuleName IS NULL )
WHERE a.RwNum <> b.RwNum
)
Saeid Hasani [sqldevelop]
No comments:
Post a Comment