title: How to select sum -or- 0 if no records exist?
body: <p>I need to write a query that returns the sum of all values that meet a certain criteria, but the query needs to return 0 if no rows are found, rather than null.  For example:</p>
  
  <pre><code>tab    
  +---------------+-----+
  | descr         | num |
  +---------------+-----+
  | hello there   | 5   |
  | hi there      | 10  |
  | hello         | 10  |
  | hi there!     | 15  |
  +---------------+-----+
  </code></pre>
  
  <p>This query:</p>
  
  <pre><code>SELECT sum(num) AS val FROM tab WHERE descr LIKE "%hello%";
  </code></pre>
  
  <p>should, and does, return <code>15</code>.  However:</p>
  
  <pre><code>SELECT sum(num) AS val FROM tab WHERE descr LIKE "%greetings%";
  </code></pre>
  
  <p>should return <code>0</code>, but does return <code>null</code>.</p>
  
  <p>Can someone explain if this is possible?</p>