Select * into maintenance_details_new_tbl from (SELECT issue_code, ROW_NUMBER() OVER(PARTITION BY issue_code ORDER BY issue_code) as RowNumber FROM maintenance_details_tbl ) AS A where RowNumber = 2