title: MYSQL Get Difference between two values
body: <p>I am wanting to calculate the difference between the max(value) returned from a database against a row value returned.</p>
  
  <p>Example Data</p>
  
  <ol>
  <li>400</li>
  <li>300</li>
  <li>200</li>
  <li>100</li>
  </ol>
  
  <p>max(value return) = 400</p>
  
  <p>Returned result should be:</p>
  
  <ol>
  <li>0 (no difference between the max value and row value) </li>
  <li>100</li>
  <li>200</li>
  <li>300</li>
  </ol>
  
  <p>etc</p>
  
  <p>Any ideas how this could achieve?</p>
  
  <p>This is current mySQL statement I am using:</p>
  
  <pre><code>SELECT userName, totalPoints , (totalPoints) AS gap
  FROM userTable
  WHERE value='1'  
  ORDER BY totalPoints DESC
  </code></pre>
  
  <p>s</p>