larrydavid
Programmer
Thanks to George who helped me with getting the hourly average of the count of total transactions:
--AVG of TxCount
SELECT AVG(TxCount * 1.0) as [AVG_CLAIM/HR] FROM
(
SELECT DATEADD(hour, DATEDIFF(hour, getdate(), t.Timestamp), getdate()) AS TxHour,
COUNT(*) AS TxCount
FROM TEST t
GROUP BY DATEDIFF(hour, getdate(), t.Timestamp)
)x
Ultimately I need to display this in an Excel chart, with the axis set-up as hours and this moving average displaying as connectors on the chart. This is why I am tryng to capture the average for previous hours throughout the day starting at 6:00 am. I realize the query above gets me the hourly average, but is there a way to capture this average as it changes throughout the day? Shouldn't it be possible to simply get previous record counts that were entered for previous hours and get those average counts? This is a toughie I can't seem to get my head around. Thanks for any help.
Thanks,
Larry
--AVG of TxCount
SELECT AVG(TxCount * 1.0) as [AVG_CLAIM/HR] FROM
(
SELECT DATEADD(hour, DATEDIFF(hour, getdate(), t.Timestamp), getdate()) AS TxHour,
COUNT(*) AS TxCount
FROM TEST t
GROUP BY DATEDIFF(hour, getdate(), t.Timestamp)
)x
Ultimately I need to display this in an Excel chart, with the axis set-up as hours and this moving average displaying as connectors on the chart. This is why I am tryng to capture the average for previous hours throughout the day starting at 6:00 am. I realize the query above gets me the hourly average, but is there a way to capture this average as it changes throughout the day? Shouldn't it be possible to simply get previous record counts that were entered for previous hours and get those average counts? This is a toughie I can't seem to get my head around. Thanks for any help.
Thanks,
Larry