Puoi usare un CTE
con un ROW_NUMBER
così:
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
Puoi usare un CTE
con un ROW_NUMBER
così:
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