I have four queries that I am using: 4 calls 3, 3 calls 2 and 1.
This was the only way to get the results I wanted, with my knowledge level.
The table it is coming from appears to have 3 keys, I am guessing that they are concatinated, Year,Incident No, and Sequence.
I was wondering if I can make a sub query to include them all, so i dont have 4 queries doing what one can.
Thanks in advance to the smart people out there.
1)
SELECT [Operation Entry].[Year Assoc], [Operation Entry].[Incident No], [Operation Entry].[Sequence No], [Operation Entry].[Outage Minutes], [Operation Entry].[KVA-Minutes], [Operation Entry].[Class ID No], [Operation Entry].RecDate
FROM [Operation Entry]
WHERE ((([Operation Entry].[Outage Minutes])>5) AND (([Operation Entry].[Class ID No])="4"));
2)
SELECT [Operation Entry].[Incident No], Max([Operation Entry]![KVA Out]) AS MaxKVAOut, [Operation Entry].[Year Assoc]
FROM [Operation Entry]
WHERE ((([Operation Entry].[Class ID No])="4"))
GROUP BY [Operation Entry].[Incident No], [Operation Entry].[Year Assoc], [Operation Entry].[Year Assoc];
3)
SELECT [1JohnTest].[Incident No], [2JohnTestMaxKva].MaxKVAOut, Sum([1JohnTest].[KVA-Minutes]) AS [SumOfKVA-Minutes]
FROM 2JohnTestMaxKva INNER JOIN 1JohnTest ON ([2JohnTestMaxKva].[Year Assoc] = [1JohnTest].[Year Assoc]) AND ([2JohnTestMaxKva].[Incident No] = [1JohnTest].[Incident No])
WHERE ((([1JohnTest].RecDate) Between [Type the beginning date:] And [Type the ending date:]))
GROUP BY [1JohnTest].[Incident No], [2JohnTestMaxKva].MaxKVAOut;
4)
SELECT Count([3JohnTestTotals].[Incident No]) AS [# Incidents], Sum([3JohnTestTotals].MaxKVAOut) AS [SAIFI KVA], Sum([3JohnTestTotals].[SumOfKVA-Minutes]) AS [KVA-Min]
FROM 3JohnTestTotals;