title: What does CASE SUM(total_of_A) WHEN 0 THEN 0 ELSE SUM(B) / SUM(total_of_A) END mean
body: <p>Trying to understand the <code>CASE</code> (Transact-SQL) expression, but ended up with lot of confusion. Can anyone please explain the following statement in simple words? </p>
  
  <pre><code>CASE SUM(total_of_A) WHEN 0 THEN 0 ELSE SUM(B) / SUM(total_of_A) END;
  </code></pre>
  
  <p>I <a href="https://msdn.microsoft.com/en-us/library/ms181765.aspx" rel="nofollow">read</a> the following, but it doesn't clear up the confusion </p>
  
  <pre><code>CASE input_expression 
      WHEN when_expression THEN result_expression [ ...n ] 
  [ELSE else_result_expression ] 
  END 
  </code></pre>