title: Get the difference between top and last value in result set
body: <p>My table looks something like </p>
  
  <pre><code>deal_id   test_value    run_date
  820117648   1.2     2014-03-31
  820117648   1.33    2014-04-30
  820117648   1.33    2014-05-30
  820117648   1.26    2014-06-30
  820117648   1.11    2014-07-31
  820117648   0.58    2014-09-30
  820117648   1.64    2014-10-31
  820117648   0.64    2014-11-28
  820117648   3.65    2014-12-31
  820117648   3.8     2015-03-11
  
  820117649   0.64    2014-09-31
  820117649   0.23    2014-10-31
  820117649   0.64    2014-11-28
  820117649   3.65    2014-12-31
  820117649   3.8     2015-03-11
  
  
  SELECT deal_id,test_value,run_date  FROM  ems.cdotests
    WHERE run_date &gt;= Dateadd(month, -4 Getdate())
  </code></pre>
  
  <p>I am trying to grab the last  4 run_date record from the whole set and then 
  I need to find the difference between the testValue on the first rundate of my select criteria and the last rundate i.e for deal_id 820117649    3.8 - 0.23 = 3.57 and for deal_id 820117648 it should be 3.8 -1.64 = 2.16
  This is the large table with multiple deal id and several run_date associated with each dealid and may have data for the last 15 years or so
  Any suggestion would be really helpfull</p>