title: Eliminate division by zero using an SQL Server CASE statement
body: <p>I am trying to eliminate this division by zero error using <code>CASE</code> in my <a href="http://en.wikipedia.org/wiki/Transact-SQL" rel="nofollow">T-SQL</a> <code>SELECT</code> statement. For some reason, I keep getting the error. Here is my logic.</p>
  
  <pre><code>SELECT 
      CASE 
         WHEN tb1.wpf = 0.000 THEN '0.000' 
         ELSE SUM(tb2.weight/tb1.wpf) 
      END AS Average 
  FROM Table1 tb1, table2 tb2 
  GROUP BY tb1.wpf
  </code></pre>
  
  <p>I did not include joins and all my logic to keep my question specific to this case. How can I get rid of this error?</p>