If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Rolling Sum

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Jan 2012
Posts: 16
Rolling Sum

Hello All,
I'm in need of some assistance with creating a rolling sum to find the sum of 3 previous months gas production. Below is an example of the basic data I will be using to find the sum.


OperatorID RRCID YearReported MonthReported YearCode DateReported GasProduction
710549 93207 2012 2 201202 2012-02-01 89
710549 93207 2012 1 201201 2012-01-01 721
710549 93207 2011 12 201112 2011-12-01 353
710549 93207 2011 11 201111 2011-11-01 409
710549 93207 2011 10 201110 2011-10-01 544
710549 93207 2011 9 201109 2011-09-01 707
710549 93207 2011 8 201108 2011-08-01 506
710549 93207 2011 7 201107 2011-07-01 536
710549 93207 2011 6 201106 2011-06-01 472


I want the sum of the Year & Month of 2012-2 to be the sum of the gas production for 2012-1, 2011-12, and 2011-11.
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
Why not select the sum of gas production where the yearcode is greater than 201111?

Maybe i misunderstand something?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On