SQL Server Group sort de duplication row_ number() over ( PARTITION BY t1.col_ 2 ORDER BY 1 )

Recall SQLServer group sort once to reanalyze

row_number() over ( PARTITION BY t1.col_2 ORDER BY 1 )

-- Code
DELETE FROM table_name t 
WHERE t.rowid IN (
	SELECT rid
	FROM(
		SELECT t1.rowid rid,row_number() over ( PARTITION BY t1.col_2 ORDER BY 1 ) rn 
		FROM table_name t1 
	) t1 
	WHERE t1.rn > 1 
);

-- PARTITION BY t1.col_2
-- The first grouping is based on the second column

-- ORDER BY 1
-- then sort by the first column

-- row_number()
-- reassign row numbers to the grouped sorted data
-- similar to a grouped set of numbers
-- for example, the first two steps are divided into three groups
-- row_number() will renumber the first group from 1, 1.2.3.4 ....
-- the second group will still be numbered from 1, 1.2.3.4 ....
-- and so on down the line

-- WHERE t1.rn > 1
-- Filter the grouped sorted data to filter out all rows numbered greater than 1 (i.e. duplicate rows)
-- keep only the first record, filter all others greater than 1 and then use t.rowid IN () to delete them to achieve de-duplication

Read More: