SQL Server
於多筆重複資料中取得該重複群組中最新一筆資料
1.EmpManager 以 Manager 進行分組,並對分組以 Date 做 DESC 排序,並為分組的排序標上編號row_seqno
SELECT ROW_NUMBER() over(PARTITION BY Manager ORDER BY Date Desc) as row_seqno, *
FROM EmpManager
2.選出 row_seqno = 1 的紀錄
SELECT temp.*
FROM (
SELECT ROW_NUMBER() over(PARTITION BY Manager ORDER BY Date Desc) as row_index, *
FROM EmpManager
) as temp
WHERE temp.row_index = 1