Skip to content

Find most recent record of each employee

November 9, 2022

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

From → SQL

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: