title: use preceding in calculation sql
body: <p>I need to calculate the column E using column B,C,D &amp; previous row of E... I have the sample statement and calculation for reference. Note that prev(E) is the preceding value of E which I need to use in calculation but am unable to.   </p>
  
  <pre><code>+---------------------------------------------------------------------------------------------------------------------------------------+  
  | TransactionDt | total_allotment(B) | invchange(C) | roomssold_flag(D) | available(E) |       samplestatement            | calculation |   
  +---------------------------------------------------------------------------------------------------------------------------------------+   
  |    1/1/16     |         5          |      0       |       null        |       5      |  E=case when D=null then B       |  5          |   
  |    1/2/16     |         5          |      0       |        1          |       4      |  E=case when C=0 then prev(E)-D  |  E=(5-1)    |   
  |    1/3/16     |         5          |      0       |        0          |       4      |  E=case when C=0 then prev(E)-D  |  E=(4-0)    |   
  |    1/4/16     |         6          |      1       |        1          |       5      |  E=case when C=1 then B-D        |  E=(6-1)    |   
  |    1/5/16     |         6          |      0       |        0          |       5      |  E=case when C=0 then prev(E)-D  |  E=(5-0)    |   
  |    1/6/16     |         7          |      1       |        1          |       6      |  E=case when C=1 then B-D        |  E=(7-1)    |   
  +---------------------------------------------------------------------------------------------------------------------------------------+  
  </code></pre>