With SQL Server 2005, we can use Row_Number() function and Partition By clause to number rows in categories So you can partition your data in Event category and filter only the rows with row number is 1 So you will get only 1 row per category
with cte as (
SELECT [Guid] ,
UserGuid ,
ReferenceGuid ,
ReferenceID ,
[Event] ,
Comments ,
[Time] ,
IPAddress,
rn = ROW_NUMBER() OVER (Partition By Event Order By Time Desc)
FROM EventLogs
)
select * from cte where rn = 1
Please check the following URL for similar sample code http://www.kodyaz.com/articles/top-n-random-rows-foreach-category-or-group.aspx[^]