question

happyalways avatar image
happyalways asked

Monthly and weekly calculation

Hi, I have a data like this, Year, scode, Month, region, person_no, annual growth 2014 1 1 C 11 356036.66 2014 1 2 H 23 531746.76 2014 1 3 D 49 775984.92 2014 1 4 H 307 592902.24 2014 1 5 A 357 457111.33 2014 1 6 H 727 614563.35 2014 2 7 C 9683 646393.17 2014 2 8 H 9687 683680.53 2014 2 9 D 9689 592353.56 2014 2 10 H 9691 671563.68 2014 2 11 A 9692 522527.94 2014 2 12 H 9696 359238.43 and i want to calculate annualgrwoth on weak basis and days basis. just we need to divide it with either by number of week or number of days. i am only worrying is there any mechanism in sql which will automatically give the number of week in a month or number of days in a month, so i can optimize my code without having more manual calculation. Kindly share your views. Thanks. Expecting records to be in below format in output Year, scode, Month, region, person_no,annual growth,WeeklyAnnualGrowth, Daily Annual Growth Thanks
sql-server-2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Mrs_Fatherjack avatar image
Mrs_Fatherjack answered
As far as I know SQL Server can't create it automatically for you however, I would do this by creating a Date Dimension table which will give you all the information you need, you would just need to join to it to get the analysis required. There is a post here http://www.sqlservercentral.com/scripts/Data+Warehousing/65762/ on how to create it.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

happyalways avatar image happyalways commented ·
Thank You Mrs_Fatherjack
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.