Du kan använda en CTE
med en ROW_NUMBER
så här:
WITH CTE AS
(
SELECT UserFK, aDate, aValue,
RN = ROW_NUMBER() OVER (PARTITION BY UserFK ORDER BY aDate DESC)
FROM dbo.TableName
)
SELECT UserFK, aDate, aValue
FROM CTE
WHERE RN = 1
Du kan använda en CTE
med en ROW_NUMBER
så här:
WITH CTE AS
(
SELECT UserFK, aDate, aValue,
RN = ROW_NUMBER() OVER (PARTITION BY UserFK ORDER BY aDate DESC)
FROM dbo.TableName
)
SELECT UserFK, aDate, aValue
FROM CTE
WHERE RN = 1