Finding Duplicates on a Column Subset with Detail
Students with same name and date of birth
Section titled “Students with same name and date of birth”WITH CTE (StudentId, Fname, LName, DOB, RowCnt)as (SELECT StudentId, FirstName, LastName, DateOfBirth as DOB, SUM(1) OVER (Partition By FirstName, LastName, DateOfBirth) as RowCntFROM tblStudent)SELECT * from CTE where RowCnt > 1ORDER BY DOB, LNameThis example uses a Common Table Expression and a Window Function to show all duplicate rows (on a subset of columns) side by side.