答案 0 :(得分:0)
试试这个:
;with cte_getlatest as(
select row_number over (partition by ProjectID) as ROWNUM,
ProjectID,
PhaseID,
WBSJobNum
FROM
[TableName]
)
SELECT * FROM cte_getlatest WHERE ROWNUM = 1;
请注意,表中行的物理顺序并不总是与没有任何指定ORDER BY
列表的查询返回的顺序相同。这里有详细记录 - SQL Order By