Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Calculate moving Average for 5 yrs

Author  Topic 

mitasid
Yak Posting Veteran

51 Posts

Posted - 2009-04-02 : 16:28:38
Hi Guys

I need to calculate the rolling averages for the cost of employees
for 5 years by taking Jan 2001 till dec for the first period and averaging the rest of years' data. to smooth out the trend lines for a graph.

Here is the sample data for your reference

Employee_code Year Month Cost
12 2001 1 $5000
11 2001 2 $1222
11 2001 3 $12444
.
.
.
144 2005 12 $8555


In my graph I want to plot the Cost on Y axis and
on X axis I have to plot Year and month along with the Doctor count for each month.



Any suggestion guys??


Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-04-02 : 17:14:00
>>Any suggestion guys??
try clicking the search link above and searching for rolling average. Lots of topics with examples.

Be One with the Optimizer
TG
Go to Top of Page

mitasid
Yak Posting Veteran

51 Posts

Posted - 2009-04-02 : 19:02:58
Hey thanks TG
I had a look at the posts in search but could not find anything specific which matched my query.

Could you please give me the actual TSQL for solving this??

Thanks
Go to Top of Page
   

- Advertisement -