title: MySQL avoiding null values for sum operations?
body: <p>I need to make a column that counts the amount of variables which are above 0, and that won't return null if there is any non-null value in it, for each value in an id column.</p>
  
  <p>What I managed to make is using a sum between some boolean operations:</p>
  
  <p><code>IF 'A' THEN 'B' ELSE 'C'</code> (at least that's what I've got)</p>
  
  <pre><code>select ID, `jul`, `aug`, `set`, `oct`, `nov`, `dec`,
  ((((not `jul`) or 1) and (`jul` or 0)) 
  +(((not `aug`) or 1) and (`aug` or 0))
  +(((not `set`) or 1) and (`set` or 0))
  +(((not `out`) or 1) and (`out` or 0))
  +(((not `nov`) or 1) and (`nov` or 0))
  +(((not `dec`) or 1) and (`dec` or 0))) as sum from table;
  </code></pre>
  
  <p>It works at first view, but if there is any null value in a line, the <code>sum</code> returns null for each respective id.</p>
  
  <p>What could I do to avoid this problem?</p>