title: MySQL: averaging with nulls
body: <p>Is there a simple way I can exclude nulls from affecting the avg? They appear to count as 0, which is not what I want. I simply don't want to take their average into account, yet here is the catch, I can't drop them from the result set, as that record has data on it that I do need.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>example:</p>
  
  <pre><code>select avg(col1+col2), count(col3) from table1
  where
  group by SomeArbitraryCol
  having avg(col1+col2) &lt; 500 and count(col3) &gt; 3
  order by avgcol1+col2) asc;
  </code></pre>
  
  <p>This would be working for me, but the averages aren't accurate as they are counting null values as 0, which is really throwing off the whole average.</p>