title: Aggregating data to get a running total month on month
body: <p>I have a table which holds the below data</p>
  
  <p><img src="https://i.stack.imgur.com/gNBPw.jpg" alt="just a snippet of the data in the table"></p>
  
  <p>This issue im having is that i need a running total for each month, I've managed to create this is an excel sheet pretty easily but when i try anything in SQL the data result varies.</p>
  
  <p>The image below shows the sum of each paid amount by month, then a total of each one added onto it. I've edited excel to show the formula and the result of the formula. Also have the result i get from SQL 2008 when using  (example only)</p>
  
  <p>***UPDATE - The result set im trying to achieve that is in the excel document is for example month 117 + Month 118 gives Month118 TotalToDate, then month 118 + 119 gives Months 119 Total to Date.</p>
  
  <p>Not sure how else to explain this?</p>
  
  <blockquote>
    <p>( select sum(paid) from #tmp005 t2 where t2.[monthid] &lt;=
    t5.[monthid] ) as paid</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/mKZF4.jpg" alt="enter image description here"></p>
  
  <p>Really feel that this is less complicated than what I think!</p>