select
CS.Name0,
max(AD.AgentTime) as ‘Date/Time’
from
dbo.v_AgentDiscoveries ad
JOIN dbo.v_GS_COMPUTER_SYSTEM cs on AD.ResourceID = CS.ResourceId
join dbo.v_FullCollectionMembership FCM on FCM.ResourceID = CS.ResourceId
Where
AgentName = ‘Heartbeat Discovery’
and FCM.CollectionID = ‘SMS00001’
Group by
CS.Name0