;with cteRowNumber as (
select COMPUTERNAME, SERIALNUMBER, USERNAME, LASTIP, LASTUPDATE, SOURCE,
row_number() over(partition by COMPUTERNAME order by LASTUPDATE desc) as RowNum
from YourTable)
select COMPUTERNAME, SERIALNUMBER, USERNAME, LASTIP, LASTUPDATE, SOURCE
from cteRowNumber
where RowNum = 1
http://stackoverflow.com/questions/4751913/retrieving-last-record-in-each-group-from-database-sql-server-2005-2008
No comments:
Post a Comment