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)
 Last 6 Month Qty for each Row

Author  Topic 

ravishwor
Starting Member

20 Posts

Posted - 2008-04-16 : 01:48:24
I have the following data in a Table. Note that this table holds Sales Qty till Today and also Forecast Qty for the next n Months (where n could be between 1 - 15 months)

YYYYMM Stock_Code Whse_code Sales_Qty
----------- ---------------- --------- ------------
200710 009040 B 505
200711 009040 B 370
200712 009040 B 385
200801 009040 B 335
200802 009040 B 305
200803 009040 B 250
200804 009040 B 250
200805 009040 B 250
200806 009040 B 250
200807 009040 B 250
200808 009040 B 250
200809 009040 B 250
200810 009040 B 250
200710 009040 M 549
200711 009040 M 565
200712 009040 M 535
200801 009040 M 685
200802 009040 M 305
200803 009040 M 240
200804 009040 M 240
200805 009040 M 240
200806 009040 M 240
200807 009040 M 240
200808 009040 M 240
200809 009040 M 240
200810 009040 M 240
200811 009040 M 240
200812 009040 M 240
200901 009040 M 240
200902 009040 M 240
200903 009040 M 240
200904 009040 M 240
200905 009040 M 240
200906 009040 M 240


How can I create a Column (6MthQtyToDate) that is the Sum of the Qty of the Last6Mths. I need this Column for each Row of data.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-16 : 02:30:02
You mean like a 6-month running total?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ravishwor
Starting Member

20 Posts

Posted - 2008-04-16 : 02:39:05
Yes.
Go to Top of Page
   

- Advertisement -