title: how to substract upper value from lower value of mysql database table column
body: <p>I have a MySQL database table like this</p>
  
  <pre><code>-------------------------------------------
  name     | distancefromstart  |  distance
  -------------------------------------------    
  AA       |    90              |
  BB       |    50              |
  CC       |    100             |
  DD       |    10              |
  </code></pre>
  
  <p>First I want to sort this table by value of the <code>distancefromstart</code> column.
  After sorting the table, the first value of <code>distancefromstart</code> should substract from second value of <code>distancefromstart</code> and second value of <code>distancefromstart</code> should substract from third value of <code>distancefromstart</code> and third value of 
  <code>distancefromstart</code> should substract from forth value of <code>distancefromstart</code> and so on.</p>
  
  <p>Then the new values should be added to the column called <code>distance</code> in the database.</p>
  
  <p>Then the updated table should be like this:</p>
  
  <pre><code>name     | distancefromstart  |  distance
  -------------------------------------------
  AA       |    10              |  40 
  BB       |    50              |  40
  CC       |    90              |  10
  DD       |    100             |   
  </code></pre>