title: Two level grouping in sql query
body: <p>I have three tables that will be used in the query: <br><br></p>
  
  <p>Departments:<br>
  DepartmentID - PK<br>
  DepartmentName<br><br><br></p>
  
  <p>Earnings:<br>
  EarningID - PK<br>
  PersonID <br>
  EarningValue<br><br><br></p>
  
  <p>People:<br>
  PersonID - PK<br>
  DepartmentID<br>
  Surname<br>
  Name<br><br></p>
  
  <p>I need to make a query that will return 4 columns:<br>
  - DepartmentName<br>
  - Surname of Person<br>
  - Sum of all Earnings of Person<br>
  - Sum of all Earnings of Department<br><br></p>
  
  <p>I was reading about ROLLUP, CUBE, and GROUPING SETS clauses, but i dont have idea how to use it here.
  An important thing is that i cannot use OVER (PARTITION</p>