title: Get counting numbers merged from same table
body: <p>I have a MySql table called 'services' with this structure: institution, Role</p>
  
  <pre><code>    Institution     |   Role
      Human Ressource |   Responsable
      Human Ressource |   Responsable
      Human Ressource |   Agent
      Human Ressource |   Agent
      Human Ressource |   Chief
      IT Service      |   Responsable
      IT Service      |   Agent
      Client Relate   |   Responsable 
      Client Relate   |   Chief
      Control Mgm     |   Responsable
      Control Mgm     |   Agent
      Control Mgm     |   Agent
  </code></pre>
  
  <p>and a query to get counting numbers of Roles per Institutions like:</p>
  
  <pre><code>    SELECT a.institution, Responsable, Agent, Chief
      FROM
      (
        SELECT a.institution
        FROM services a
        WHERE a.month = '2019-04'
        GROUP BY a.institution
      ) a,
      (
        SELECT b.institution, NULLIF(count(b.role) ,0) AS Responsable
        FROM services b
        WHERE
          b.month = '2019-04' AND
          b.role = 'Responsable'
        GROUP BY b.institution
      ) b,
      (
        SELECT c.institution, NULLIF(count(c.role), 0) AS Agent
        FROM services c
        WHERE
          c.month = '2019-04' AND
          c.role = 'Agent'
        GROUP BY c.institution
      ) c,
      (
        SELECT d.institution, NULLIF(count(d.role), 0) AS Chief
        FROM services d
        WHERE
          d.month = '2019-04' AND
          d.role = 'Chief'
        GROUP BY d.institution
      ) d
      WHERE
        a.institution = b.institution AND
        a.institution = d.institution
      GROUP BY 1
      ORDER BY a.institution ASC
  </code></pre>
  
  <p>What I want to achive in one sql statement is a result like:</p>
  
  <pre><code>    Institution     |   Responsable |   Agent   |   Chief   
      Human Ressource |   2           |   2       |   1
      IT Service      |   1           |   1       |   0
      Client Relate   |   1           |   0       |   1
      Control Mgm     |   1           |   2       |   0
  </code></pre>
  
  <p>But i obtain a very strange resultset</p>
  
  <pre><code>    institution     |   Responsable |   Agent   |   Chief
      Client Relate   |   1           |   2       |   1
      Human Ressource |   2           |   2       |   1
  </code></pre>
  
  <p>I've created here a <a href="http://sqlfiddle.com/#!9/7163f5/1" rel="nofollow noreferrer">sqlfiddle</a> </p>
  
  <p>Any idea will be highly appreciated. Tnx</p>