title: tsql conditional maths equation
body: <p>I need to perform some summations during a select query however depending on 2 values i will need to perform a different equation.  hopefully an example will demonstrate</p>
  
  <p>basically i need to perform the following summations</p>
  
  <pre><code>if x &gt; y then (x - y + z) or
  if x &lt; y then (x - x + z) basically i am setting this to 0.
  </code></pre>
  
  <p>So far i thought that i could use 2 tables to dump the x > y values and the x &lt; y values and then perform the relevant equations.</p>
  
  <p>any ideas</p>