title: How to generate column that calculate with its predecessor value in SQL Server
body: <p>For example</p>
  
  <pre><code>Amount   ReceivedAmount   PendingAmount
  ---------------------------------------
   1000         400             600       
    600         400             200
  </code></pre>
  
  <p>How to I get (600) value in <code>Amount</code> column?</p>
  
  <p>The table structure is </p>
  
  <pre><code>1. BillID,Amount,Date from table1
  </code></pre>
  
  <p>and</p>
  
  <pre><code>2. BillReceive,ReceiveDate,ReceivedAmount from table2
  </code></pre>
  
  <p>Received Amount Can be multiple time, I want pending amount from <code>(Amount - SUM(ReceivedAmount))</code></p>