I have a table that contains the following:
ID Node LoadTime DateTimeCST Failed
-----------------------------------------
I am trying to write a query that will return the following table (Node is DISTINCT).
Node TodaysAverageLoadTime HistoricalLoadTime
----------------------------------------------------
So, I am basically trying to take an average of LoadTime for the past 24 hours, then another average of LoadTime that averages all the data that is in the table for LoadTime. This is the query I was using to just get today’s average.
SELECT DISTINCT Node, AVG(LoadTime)
FROM dbo.Table
WHERE Failed != 1
AND DATEDIFF(day, DateTimeCST, GETDATE()) = 0
GROUP BY Node
What would I need to add to this query to also average LoadTime for all records? Any help would be greatly appreciated. Thanks.
Since the criterion to identify the records for TodaysAverageLoadTime and that for HistoricalLoadTime is different, it can’t be done in a single query. But you can simulate it as follows: