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
 General SQL Server Forums
 New to SQL Server Programming
 Weekly comparison Prior Year vs Current Year

Author  Topic 

cmrrive
Starting Member

6 Posts

Posted - 2012-04-05 : 14:00:49
I need some help.

The final report will look like this
03/1/11 03/2/11 03/3/11 03/04/11 03/5/11
Monday Tuesday Wednesday Thursday Friday Saturday

Prior
Year 0 100 100 1000 150 250

Cur
Year 0 0 0 1000 100 1000

So I have to compare the 1st week of March 2011 with the firts week of March 2012 (and day by day like Monday, Tuesday, etc)

I have a table with already with the following info

date, Amount


Any help on how to built the final table?.


miguel

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-05 : 14:16:52
you need to apply pivot

see

http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -