title: SQL COUNT() function and LEFT OUTER JOIN
body: <p>I have two tables, users and departments. I want to have table, where are two columns: first is department name, second is count - how many users are assigned to this department.
  And I have this piece of code:</p>
  
  <pre><code>SELECT department_name as 'deptName', 
         COUNT(users.department_id) as 'userCount' 
  FROM departments
  LEFT OUTER JOIN users
  ON departments.id = users.department_id 
  GROUP BY 'deptName'
  </code></pre>
  
  <p>Department's table columns are:</p>
  
  <pre><code> integer id PK
  
   varchar(20) department_name
  </code></pre>
  
  <p>User's table columns are:</p>
  
  <pre><code> integer id PK
  
   varchar(20) name
  
   varchar(20) surname
  
   int department_id FK
  </code></pre>
  
  <p><strong>But it does not work.</strong></p>
  
  <p>Now I have 2 departments, and output should be 2 rows, first with count 8 and second with count 1. <strong>But I see only one row, with all count  (9).</strong>
  I use MySQL installed with XAMPP.</p>