Rolling Sum with SQL
446742Aug 14 2005 — edited Aug 14 2005Hi,
I am looking for a solution of rolling sum of 2 weeks, and I DON'T want to use "over (partition by week_date order by week_date)".
TABLE LOOKS as BELOW,
WEEK_DATE QTY PROD_NAME
-------------------- ------- ---------------------
7/29/2005 18 PROD1
7/22/2005 10 PROD1
7/15/2005 16 PROD1
7/8/2005 20 PROD1
Output should look like below,
WEEK_DATE QTY PROD_NAME ROLL_SUM
-------------------- ------- --------------------- --------
7/8/2005 20 PROD1 30 ( sum of pervious week)
7/15/2005 16 PROD1 36
7/22/2005 10 PROD1 26
7/29/2005 18 PROD1 28
Thanks In Advance,
-Shirish