title: SQL - LEFT JOIN, but I want COUNT(*) to only count the results from the INNER part of the join
body: <p>I want to display the number of purchases each customer has made. If they've made 0 purchases, I want to display 0.</p>
  
  <p><strong>Desired Output:</strong></p>
  
  <pre><code> -------------------------------------
  | customer_name | number_of_purchases |
   -------------------------------------
  |    Marg       |          0          |
  |    Ben        |          1          |
  |    Phil       |          4          |
  |    Steve      |          0          |
   -------------------------------------
  </code></pre>
  
  <p><strong>Customer</strong> Table:</p>
  
  <pre><code> -----------------------------
  | customer_id | customer_name |
   -----------------------------
  |      1      |      Marg     |
  |      2      |      Ben      |
  |      3      |      Phil     |
  |      4      |      Steve    |
   -----------------------------
  </code></pre>
  
  <p><strong>Purchases</strong> Table:</p>
  
  <pre><code> --------------------------------------------------
  | purchase_id | customer_id | purchase_description |
   --------------------------------------------------
  |      1      |       2     |     500 Reams        |
  |      2      |       3     |     6 Toners         |
  |      3      |       3     |     20 Staplers      |
  |      4      |       3     |     2 Copiers        |
  |      5      |       3     |     9 Name Plaques   |
   --------------------------------------------------
  </code></pre>
  
  <hr>
  
  <p>My current query is as follows:</p>
  
  <pre><code>SELECT customer_name, COUNT(*) AS number_of_purchaes 
  FROM customer 
  LEFT JOIN purchases ON customer.customer_id = purchases.customer_id 
  GROUP BY customer.customer_id
  </code></pre>
  
  <p>However, since it's a <code>LEFT JOIN</code>, the query results in rows for customers with no purchases, which makes them part of the <code>COUNT(*)</code>. In other words, customers who've made 0 purchases are displayed as having made 1 purchase, like so:</p>
  
  <p><strong>LEFT JOIN Output:</strong></p>
  
  <pre><code> -------------------------------------
  | customer_name | number_of_purchases |
   -------------------------------------
  |    Marg       |          1          |
  |    Ben        |          1          |
  |    Phil       |          4          |
  |    Steve      |          1          |
   -------------------------------------
  </code></pre>
  
  <p>I've also tried an <code>INNER JOIN</code>, but that results in customers with 0 purchases not showing at all:</p>
  
  <p><strong>INNER JOIN Output:</strong></p>
  
  <pre><code> -------------------------------------
  | customer_name | number_of_purchases |
   -------------------------------------
  |    Ben        |          1          |
  |    Phil       |          4          |
   -------------------------------------
  </code></pre>
  
  <p>How could I achieve my <strong>Desired Output</strong> where customers with 0 purchases are shown?</p>