title: SQL - Teams and Their Player Count
body: <p>I'd need some help here. Im stuck on this SQL Query.</p>
  
  <p>I have 2 Tables team and function. Team contains <code>ID</code>,<code>Teamname</code>. Function contains <code>ID</code>,<code>Role</code></p>
  
  <p>role decides whether a person is a player or a coach (0 for player, 1 for coach).</p>
  
  <p>I am supposed to list all teams that exists, but they should only count players and even teams with no players should be listed to. There's teams that only have coaches for example.</p>
  
  <p>i can't find any way to count everyone within a team.</p>
  
  <p>This is the closest I've come:</p>
  
  <pre><code>select teamname, 
         count(*) 
  from function left outer join team on team.id = function.id 
  WHERE role=0 
  group by teamname;
  </code></pre>