title: MySql IF in WHERE query when a column has negative and positive values
body: <p>I am trying to write a query like</p>
  
  <pre><code>SELECT SUM(a.payment_value) AS paymentvalue 
  FROM tableA a 
  WHERE IF (a.column_3 &lt;&gt; 'UOB' AND a.column_3 &lt;&gt; 'Affin', 
    a.payment_value &gt; 0, 
   {else a.payment_value can be positive and negative value}) 
  GROUP BY a.column_3;
  </code></pre>
  
  <p>The query is to</p>
  
  <ol>
  <li>sum column a.payment_value Group by <code>a.column_3</code></li>
  <li>condition 1, <code>if a.column_3 is not 'UOB' or 'AFFIN'</code>, select and only sum positive value</li>
  <li>condition 2, <code>if a.column_3 is UOB' or 'AFFIN'</code>, select and sum positive and negative values</li>
  </ol>
  
  <p>I tried the following (supposedly to sum 2 lines -> 1000 + (-5) = 995) but returns only -5 as the paymentvalue and not the summed.</p>
  
  <pre><code>SELECT SUM(a.payment_value) AS paymentvalue 
  FROM tableA a 
  WHERE IF (a.column_3 &lt;&gt; 'UOB' AND a.column_3 &lt;&gt; 'Affin', a.payment_value &gt; 0, a.payment_value &gt; 0 OR a.payment_value &gt; 0) 
  GROUP BY a.column_3;
  </code></pre>
  
  <p>How should I write the IF in WHERE clause with these conditions?</p>