So I want to DELETE the duplicate rows not just FIND IT My current code can only let me know which ROWS have to be deleted. But I am confusing how to "DELETE" them from my target table. Any suggestion?
WITH tmp AS ( SELECT Code ,ROW_NUMBER() OVER(PARTITION BY Code ORDER BY Code) AS ROWNUMBER FROM CouponCode ) SELECT * FROM tmp WHERE ROWNUMBER > 1 