title: getting the difference between two rows and perform mathematical operation on the difference mysql
body: <p>My data set for example looks like this</p>
  
  <pre><code>ID|Value
   1|10
   1|3
   2|9
   2|10
   2|15
  </code></pre>
  
  <p>I need to find the difference between two consecutive elements of the same ID and store the value and then again find the difference and multiply the stored value with the new difference all of values with the same ID. This must go on till there are elements with the same ID.
  Hence my final data set should looklike  </p>
  
  <pre><code>ID|Value
   1|-7
   2|5
  </code></pre>
  
  <p>Does anyone have any suggestions how i should go about this using sql</p>