Hey guys, thanks in advance for any help. I found an AWOL machine reporton Connect a while back that we have been using but I noticed it includes retired assets. I was curious if anyone had any idea on what I could do to make sure that only active/non-retired machines showed up in this report. The sql for this is below:
DECLARE @days int
SET @days = 14
SELECT ci.[Guid]
, ci.[Name]
, ISNULL(ir.[Collection Time], eh.[LastInvEvt]) [Last Inventory]
FROM vRM_Computer_Item ci
LEFT OUTER JOIN Inv_Inventory_Results ir
ON ci.[Guid] = ir.[_ResourceGuid]
AND ir.[Agent] = 'Inventory Agent'
LEFT OUTER JOIN (
SELECT MAX(_eventTime) [LastInvEvt], [ResourceGuid]
FROM Evt_NS_Event_History
WHERE ItemName = 'Inventory Solution Capture Item'
GROUP BY ResourceGuid
) eh ON eh.[ResourceGuid] = ci.[Guid]
WHERE DATEADD(DAY, @days, ISNULL(ir.[Collection Time],ISNULL(eh.[LastInvEvt],''))) < GETDATE()
AND ci.[IsManaged] = 1
ORDER BY ci.[Name] ASC
Thanks again!!!