• For readability's sake if nothing else, I would probably wrap the RowNumber in a CTE and delete from there. It might even be more efficient, especially in the second example where the PARTITION BY clause is not used and we are forced to execute the select statement twice.

    Unfortunately, I don't have a SQL server in front of my right now, so I'm not able to test that theory right now. Likely that may only be the case with smaller recordsets.

    ;

    WITH cteDuplicateRows as (

    select

    Emp_Name

    , Company

    , Join_Date

    , Resigned_Date

    , RowNumber = ROW_NUMBER() over (

    partition by Emp_Name, Company, Join_Date, Resigned_Date

    order by Emp_Name, Company, Join_Date, Resigned_Date

    )

    from Emp_Details

    )

    Delete cteDuplicateRows

    where a.RowNumber > 1