title: How to write a SQL to cascadingly accumulate rows of data?
body: <p>I have a work plan in DB as follows. For instance, the first row means that Team A has 10 hours' work to do in June (SP1006).</p>
  
  <pre>
  Team Sprint  WorkHours
  A    1006    10
  A    1007    20
  A    1008    30
  A    1009    40
  B    1008    50
  B    1009    60
  B    1010    70
  </pre>
  
  <p>I want to derive it into the following form to show: at the end of each month, how many hours are left to be done, according to the work plan. As you see, the fields of the derived table depend on the original datatable too.</p>
  
  <pre>
  Team    SP1005  SP1006  SP1007  SP1008  SP1009  SP1010
  A       100     90      70      40      0       0
  B       180     180     180     130     70      0
  </pre>
  
  <p>I'm trying to do this on SQL Server 2000. This is really hard for me. Can someone give some help? Thanks a lot!</p>
  
  <p><strong>Edit:</strong> Or you can ignore the row-to-column transformation part, (which I know how to do,) just concentrate on the accumulation part.</p>