title: SQL - subtract value from same column
body: <p>I have a table as follows</p>
  
  <pre><code>fab_id  x  y  z  m  
  12      14 10 3  5
  12      10 10 3  4
  </code></pre>
  
  <p>Here im using group by clause on id .Now i want to  subtract those column values which have similar id. 
  e.g group by on id (12). Now to subtract (14-10)X, (10-10)Y, (3-3)z, (5-4)m</p>
  
  <p>I know there is a aggregate function sum for addition but is there any function which i can use to subtract this value.</p>
  
  <p>Or is there any other method to achieve the results.</p>
  
  <p>Note- There may be a change that value may come in -ve. So any function handle this?</p>
  
  <p>one more example - (order by correction_date desc so result will show recent correction first)</p>
  
  <pre><code>fab_id  x  y  z  m  correction_date
  14      20 12 4  4   2014-05-05 09:03
  14      24 12 4  3   2014-05-05 08:05
  14      26 12 4  6   2014-05-05 07:12
  </code></pre>
  
  <p>so result to achieve group by on id (14). Now to subtract (26-20)X, (12-12)Y, (4-4)z, (6-4)m</p>