我的查询返回每个用户 ID 的最新条目,但我需要它返回每个用户 ID 和任务名的最新条目。我尝试使用 group by,但出现错误。有什么我做错了吗?谢谢!
SELECT UserId, TaskName, First, Last, email, ValueDate, Analysis
FROM (SELECT UserId, TaskName, First, Last,
email, ValueDate, Analysis,
ROW_NUMBER() OVER(PARTITION BY UserID
ORDER BY ValueDate DESC) AS rk
FROM MyTable) AS L
WHERE rk = 1