title: SQL Stored Procedure Divide by zero error encountered.
body: <p>Trying to figure out why my stored procedure is giving me a "divide by zero" error and I've narrowed it down to this area. If I comment the follow lines out the query runs successfully. I am not sure why though.</p>
  
  <pre><code>            PartReceived.QuantityReceived / 
              (CASE 
                  WHEN PurchaseOrderItem.QuantityOrdered IS NULL THEN PurchaseOrderItem.QuantityOrdered
                  WHEN PurchaseOrderItem.QuantityOrdered = 0 THEN PurchaseOrderItem.QuantityOrdered
                  ELSE PurchaseOrderItem.QuantityOrdered
              END) * 100.0 AS PercentageReceived
  </code></pre>
  
  <p>I do get this warning before the error but I've done much of what any google search has lead me to do. I've tried using IFNULL instead of IS NULL THEN but that didn't seem to work either.</p>
  
  <pre><code>Warning: Null value is eliminated by an aggregate or other SET operation.
  </code></pre>