Sorry for the late reply, I have been busy.
Here is how I would solve it using TSQL:
-- create temp table
CREATE TABLE #viewReportMonitorCounterLog
([Machine] VARCHAR(10) NOT NULL
,[Counter Instance] VARCHAR(10) NOT NULL
,[Counter Object] VARCHAR(10) NOT NULL
,[Value] NUMERIC(4,2) NOT NULL
);
-- populate temp table with sample values
INSERT INTO #viewReportMonitorCounterLog([Machine],[Counter Instance],[Counter Object],[Value])
VALUES ('Server 1','C:','A',70.00)
,('Server 1','C:','B',61.87)
,('Server 1','E:','A',84.64)
,('Server 2','C:','A',37.27)
,('Server 2','D:','A',57.00)
,('Server 2','E:','A',55.61)
,('Server 3','C:','A',20.00)
,('Server 3','E:','A',46.89);
--SELECT * FROM #viewReportMonitorCounterLog;
-- calculate average values per counter instance
SELECT
[Machine]
,[Counter Instance]
,[Avg Value] = AVG([Value])
FROM #viewReportMonitorCounterLog
GROUP BY [Machine], [Counter Instance];
-- calculate critical utilisation
WITH cte_AvgValue AS
(
SELECT
[Machine]
,[Counter Instance]
,[Avg Value] = AVG([Value])
FROM #viewReportMonitorCounterLog
GROUP BY [Machine], [Counter Instance]
) -- same select as before
,cte_Criticals AS
(
SELECT [Machine], MaxValue = MAX([Avg Value]) -- get the highest average value for the current machine
FROM cte_AvgValue
GROUP BY [Machine]
HAVING MAX([Avg Value]) >= 80.00 -- only keep the machines that are critical
)
SELECT [Number of Machines Exceeding Critical Utilisation Values] = COUNT(*)
FROM cte_Criticals;
DROP TABLE #viewReportMonitorCounterLog;
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP