If you are using SQL SErver 2005 or later (you did not specify ...), you can use CTE to do this:
;WITH MostCurrent AS ( SELECT id, hostname, group, member, datequeried, ROW_NUMBER() OVER(PARTITION BY hostname ORDER BY datequeried DESC) 'RowNum' FROM dbo.YourTable ) SELECT * FROM MostCurrent WHERE RowNum = 1
The internal SELECT inside the CTE "splits" your data into hostname , for example. each hostname receives a new βgroupβ of data, and it enters numbers starting with 1 for each group. These entries are numbered on datequeried DESC , so the most recent one has RowNum = 1 - for each data group (for example, for each hostname ).
source share