title: Count null columns as zeros with oracle
body: <hr>
  
  <p>I am running a query with Oracle:</p>
  
  <pre><code>SELECT
      c.customer_number,
      COUNT(DISTINCT o.ORDER_NUMBER),
      COUNT(DISTINCT q.QUOTE_NUMBER)
  FROM
      Customer c
      JOIN Orders o on c.customer_number = o.party_number
      JOIN Quote q on c.customer_number = q.account_number
  GROUP BY
      c.customer_number
  </code></pre>
  
  <p>This works beautifully and I can get the customer and their order and quote counts.</p>
  
  <p>However, not all customers have orders or quotes but I still want their data.  When I use <code>LEFT JOIN</code> I get this error from Oracle:</p>
  
  <blockquote>
    <p>ORA-24347: Warning of a NULL column in an aggregate function</p>
  </blockquote>
  
  <p>Seemingly this error is caused by the eventual <code>COUNT(NULL)</code> for customers that are missing orders and/or quotes.</p>
  
  <p>How can I get a <code>COUNT</code> of null values to come out to 0 in this query?</p>
  
  <p>I can do <code>COUNT(DISTINCT NVL(o.ORDER_NUMBER, 0))</code> but then the counts will come out to <code>1</code> if orders/quotes are missing which is no good.  Using <code>NVL(o.ORDER_NUMBER, NULL)</code> has the same problem.</p>