Created
June 28, 2012 07:55
-
-
Save Mpdreamz/3009771 to your computer and use it in GitHub Desktop.
Dedup CTE awesomeness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH CTE (Colum1, Colum2, DuplicateCount) | |
AS | |
( | |
SELECT Colum1, Colum2, ROW_NUMBER() | |
OVER(PARTITION BY Colum1, Colum2 ORDER BY Colum1) AS DuplicateCount | |
FROM MyTable | |
WHERE Colum1 = 1 AND Colum2 IS NOT NULL | |
) | |
SELECT * FROM CTE | |
WHERE DuplicateCount > 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment