text: ﻿SET NOCOUNT ON;
  
  SELECT Count(*)  
  FROM
      dbo.v_gs_threats t INNER JOIN dbo.vsms_r_system c ON t.resourceid = c.itemkey
                         INNER JOIN dbo.v_threatcatalog tc ON t.threatid = tc.threatid
  WHERE
      c.obsolete0 = 0 AND
      c.decommissioned0 = 0 AND
      t.DetectionTime >= CAST(DATEADD(d,-@retention,GETDATE()) as DATE);
  