title: Can I sum a calculation between two columns in Mysql?
body: <p>What I would like to do is the following:</p>
  
  <pre><code>SELECT SUM(ABS(`number_x` - `number_y`)) AS `total_difference` FROM `table`
  </code></pre>
  
  <p>Where the table is as follow:</p>
  
  <blockquote>
    <p>id  |  number_x  |  number_y</p>
    
    <p>1   |  4         |  2</p>
    
    <p>2   |  3         |  2</p>
    
    <p>3   |  2         |  4</p>
  </blockquote>
  
  <p>So the answer should be:
  (4 - 2 = 2) + (3 - 2 = 1) + (2 - 4 = 2) = 5</p>
  
  <p>Can I do this in MySQL and how?</p>
  
  <p>Thanks!</p>