0
我的查詢返回每個用戶標識的最新條目,但我需要它返回每個用戶標識和任務名稱的最新條目。我試圖用group by,但是我得到一個錯誤。有什麼我做錯了嗎?謝謝!SQL Server查詢
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