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.
| Author |
Topic |
|
khushi2005
Starting Member
2 Posts |
Posted - 2009-03-03 : 08:52:37
|
| Is there a way to calculate year to year growth rates using SQL queryI am trying to use SQL Reporting Services and MAtrix control in that It is very difficult to add a growth rate columns after ther MatrixHence I thught maybe I can calculate Growth Rate column and then have another Matrix which will display this Growth RateI know it should a self join on tables I am using but somehow my first year is getting skippedselect d.id,d.year,d.Val ,d.Val- d1.Valfrom table1 djoin table1 d1 on d1.id=d.id and d.year-1=d1.yearThanks in advance |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-03 : 09:00:37
|
| post sample data and output. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-03 : 09:00:41
|
| [code]select d.id,d.year,d.Val ,d.Val- coalesce(d1.Val,0)from table1 douter apply (select sum(Val) AS Val from table1 where id=d.id and d.year-1=year )d1 [/code] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|