title: In Db2 how to calculate difference of adjacent rows
body: <p>I want to calculate the range as row1-row2, need help in db2 query to get the range column</p>
  
  <pre><code>name,age,range   
  a,40,0     
  b,20,20  
  c,7,13  
  d,5,2  
  e,1,4  
  </code></pre>
  
  <p>Range column calculation  </p>
  
  <pre><code>first value is 0  
  (40-20)  
  (20-7)  
  (7-5)  
  (5-1)  
  </code></pre>