Find most recent record of each employee
SELECT t1.*
FROM
[empDetails] t1
INNER JOIN
(
SELECT Alias, MAX(ModifiedDateTime) AS MaxDate
FROM [empDetails]
GROUP BY Alias
) t2
ON t1.Alias=t2.Alias
AND t1.ModifiedDateTime=t2.MaxDate order by Alias, ModifiedDateTime DESC
Leave a Comment