title: SQL query to average values only if more than one value, not equal to 0, exits?
body: <p>I only want to calculate an AVG of values if two or more non-zero values exist for a specific item_id. If two or more non-zero values do not exist, I do not want to calculate the AVG.</p>
  
  <p>The current SQL is below.  Perhaps there should be an if clause first?...  any ideas?</p>
  
  <pre><code>SELECT AVG( days_since ) AS days_out
    FROM (
      SELECT days_since
      FROM user_123
      WHERE item_id = 645
  AND days_since &lt;&gt; 0
  ORDER BY id DESC
      LIMIT 5
    ) AS recent 
  </code></pre>
  
  <p>Seems like an If clause might work;</p>
  
  <pre><code>IF SELECT COUNT (*), item_id, days_since &gt;= 2 
  where days_since &lt;&gt;0, then perform AVG...
  </code></pre>