SQLTeam.com | Weblogs | Forums

Calculating moving averages between date x and date y


I am trying to calculate a moving average in my sql script. It is a moving average because users supply a date range. For example,

On top of this query, I am building a ssrs report that basically enables users to put in two dates. So as a user, I want to find out what the average count is between date x and date y for each different hospital.

In my query, how do I include the average calculation? If you just do avg(counts), then how will it be the average for date x and date y?

Say users want to see the average count for all hospitals between 10/19/2015 to 11/30/2015. How will I get it to show just a straight line on the graph for avg between the two dates?