title: SQL difference of two rows
body: <p>I have a table, <strong>Table1</strong></p>
  
  <pre><code>Table1
  ID  REG  VALUE
  1   54   500
  2   54   1700
  3   60   5000
  4   60   5500
  </code></pre>
  
  <p>Now, i need to copy rows from this table to a second one, <strong>Table2</strong>, but for entries with the same <code>REG</code> i want to make single row in the second table,with the difference between the highest <code>VALUE</code> and the lower <code>VALUE</code>, something like this:</p>
  
  <pre><code>Table2
  ID  REG  VALUE
  1   54   1200
  2   60   500
  </code></pre>
  
  <p>How can I do this?</p>