I have a database table called Events that has the following columns: [Event_ID][Date_Time][Computer][User] I am trying to find the most recent [Date_Time] for each distinct [Computer] and [User] SELECT DISTINCT [Date_Time],[Computer],[User] will give me every row as [Date_Time] makes them all unique. Doing a SELECT DISTINCT [Computer], [User] is perfect, except it doesn't have the most recent [Date_Time] with it. Thanks in advance, I am sure the answer is obvious to you all and I am just missing something simple.
One of the ways to do it is to use MAX(): --not sure why my Format SQL button doesn't work! SELECT [Computer] , [User] , MAX([Date_Time]) AS Latest_Date_Time FROM dbo.Table GROUP BY [Computer] , [User] It will most def. help if you have an index on dbo.Table -- [Computer],[User],[Date_Time].