title: counting the result of a query
body: <pre><code>Person table
  ---------------------
  |email (pk)   | name|
  ---------------------
  |a@hotmail.com| A   |
  |b@hotmail.com| B   |
  |c@hotmail.com| C   |
  
   Role table
  ---------------------------------
  |Role               |Power     |
  -------------------------------|
  |Primary            |20        |
  |Secondary          |10        |
  |Supervisor         |30        |
  --------------------------------
  Assignment table
  ------------------------------------------------------------------
  |Team Name| Term    | Role      |Email         |Join_date
  ------------------------------------------------------------------
  |AA       |2013_1   |Supervisor |a@hotmail.com |2013-08-05
  |BB       |2013_1   |Secondary  |a@hotmail.com |2013-08-05
  |CC       |2013_1   |Supervisor |c@hotmail.com |2013-08-05
  |DD       |2013_1   |Secondary  |a@hotmail.com |2013-08-05
  |AA       |2013_1   |Secondary  |b@hotmail.com |2013-08-05
  </code></pre>
  
  <p>My expected result </p>
  
  <pre><code>|name | email        | num_of_time_pri | num_of_time_sec | num_of_time_sup|
  ---------------------------------------------------------------------------------------
  |A    | a@hotmail.com|0                |2                | 1              |
  |B    | b@hotmail.com|0                |1                | 0              |
  |C    | c@hotmail.com|0                |0                | 1              |
  </code></pre>
  
  <p>Given a term, eg <code>2013_1</code> I have to find all the person who is assigned to least one role. And count how many of each role the person is assigned to.</p>
  
  <p>Using this query:</p>
  
  <pre><code>select 
        distinct p.name,
        p.email 
   from assignment a,person p 
   where term ='2013_1' and 
         a.email = p.email;
  </code></pre>
  
  <p>assume it returns 3 rows as seen in person table. And from there, I want to get the expected result table. How do I continue from there? </p>