title: Query giving division by zero error in PostgreSQL
body: <p>I am trying to run the following query which results me <code>postgres error: division by zero</code></p>
  
  <pre><code>select 
      request_count,
      response_count, 
      (response_count*100) / (request_count+response_count) AS proportion 
  from total_dummy_table; 
  </code></pre>
  
  <p>How can I avoid and resolve the <code>division by zero</code> error?</p>
  
  <p>Tried to fix using the below query but getting the same result as above</p>
  
  <pre><code>SELECT 
      request_count,
      response_count,
      (response_count*100) / (request_count) AS proportion 
  FROM 
      total_dummy_table
  ORDER BY 
      (response_count*100) /(CASE request_count WHEN 0 Then NULL ELSE request_count END) DESC NULLS FIRST
  </code></pre>
  
  <p>Please let me know where am I doing wrong, or how can I fix this.
  Thanks!</p>
  
  <p><strong>Result expectation:</strong></p>
  
  <p>The query should return me something like below:</p>
  
  <pre><code>Request_count | Response_count | Proportion
  
  1603423       |  585706        | 36.52
  </code></pre>
  
  <p><strong>Quick note:</strong> Table total_dummy_table does not have column name <code>proportion</code> that is the addition to the result which have calculated proportion in it.</p>