• A minor quibble on the ROW_NUMBER() examples: the ORDER BY clause is pointless since it repeats the PARTITION BY expression list. The ORDER BY list controls the order within each partition, not the whole result set, so none of the expressions in the PARTITION BY list should appear in the ORDER BY list since all rows in a partition share the same values for those expressions.

    If you don't want to just remove the ORDER BY clause you could adapt the examples to ORDER BY something that is guaranteed to be unique within a partition, e.g. if Emp_Details has a surrogate key column Emp_ID which is unique you could change your first example to

    select Emp_Name

    ,Company

    ,Join_Date

    ,Resigned_Date

    ,ROW_NUMBER() over (partition by Emp_Name, Company, Join_Date

    ,Resigned_Date

    order by Emp_ID) RowNumber

    from Emp_Details