title: SQL query to get the subtotal of some rows
body: <p>What would be the SQL query script if I want to get the total items and total revenue for each manager including his team? <br/>
  Suppose I have this table <code>items_revenue</code> with columns:  <br/></p>
  
  <p><code>|  id  |is_manager|manager_id|   name   |no_of_items| revenue | 
   |   1  |    1     |    0     | Manager1 |    621    |   833   | 
   |   2  |    1     |    0     | Manager2 |    458    |   627   |
   |   3  |    1     |    0     | Manager3 |    872    |   1027  | 
  ...
   |   8  |    0     |    1     | Member1  |    1258   |   1582  |
   |   9  |    0     |    2     | Member2  |    5340   |   8827  |
   |  10  |    0     |    3     | Member3  |    3259   |   5124  |</code></p>
  
  <p>All the managers and their respective members are in the above view table. Member1 is under Manager1, Member2 is under Manager2, and so on, but real data are in random arrangement. I also have a view table with <code>managers</code> where I filtered only the managers. I tried getting the totals per team manager with this query: <br/>
  <code>SELECT id, is_manager, manager_id, name, SUM(no_of_items) AS total_items, SUM(revenue) AS total_revenue
  FROM items_revenue t
  WHERE (SELECT m.id FROM managers m WHERE m.id = t.id)
  GROUP BY id HAVING id IN (SELECT m.id FROM managers m);</code></p>
  
  <p>However, it only returns the totals of each manager alone, it does not get the totals of their members. </p>
  
  <p>I want my query to output the ff. table:<br>
  <code>|  id  |is_manager|manager_id|   name   |total_items| total_revenue | 
   |   1  |     1    |    0     | Manager1 |   1879    |    2415       | 
   |   2  |     1    |    0     | Manager2 |   5798    |    9454       |
   |   3  |     1    |    0     | Manager3 |   4131    |    6151       |</code></p>
  
  <p>Any ideas how to get this? Any help would be greatly appreciated. Thanks!</p>