0 Replies Latest reply on Jul 2, 2013 4:17 PM by crmiller

    Custom SQL Query To Return Average Availability for a Group of Servers

    crmiller

      No matter which start date I begin with, the return value is always the same number. I tried one beginning in 2009 until today and it was the same number (100%). I call shenanigans on this custom SQL statement. Any ideas?

       

      SET DATEFIRST 6;

      SELECT 'Whatever Servers' AS Servers,

      AVG(ResponseTime.Availability) AS AVERAGE_of_Availability,

      DATEADD(DD, 1-DATEPART(DW, GETDATE()), DATEADD(ww,-1,GETDATE())) AS Start_Date,

      DATEADD(DD, 7-DATEPART(DW, GETDATE()), DATEADD(ww,-1,GETDATE())) AS End_Date

       

       

      FROM

      Nodes INNER JOIN ResponseTime ON (Nodes.NodeID = ResponseTime.NodeID)

       

       

      WHERE

      ( DATEPART(ww,DateTime) = DATEPART(ww, DATEADD(ww,-1,GetDate())) )

      AND 

      ( Nodes.Whatever= 1 )