Můžete použít CTE
s ROW_NUMBER
takhle:
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
Můžete použít CTE
s ROW_NUMBER
takhle:
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