title: Is it possible to group results together after, well, grouping them together?
body: <p>Table Structure 1 (clockins):
  date | timein | timeout | jobcode | jobrate | employeeid</p>
  
  <p>Table Structure 2 (jobdesc):
  jobcode | jobdescription</p>
  
  <p>So I have a query that does:</p>
  
  <pre><code>SELECT
      jd.jobdescription,
      ci.employeeid,
      ci.jobcode,
      SUM(timestampdiff(minute,ci.timein,ci.timeout) / 60) * ci.jobrate
  FROM clockins ci
  RIGHT JOIN jobdesc jd ON ci.jobcode = jd.jobcode
  WHERE ci.date BETWEEN '0000-00-00' AND '0000-00-00'
  AND jobrate &lt; 100 /* need this to distinguish salaried employees */ 
  GROUP BY `jobcode` , `employeeid`
  </code></pre>
  
  <p>This outputs data like:</p>
  
  <p><a href="https://i.stack.imgur.com/yIyde.png" rel="nofollow noreferrer">example output</a></p>
  
  <p>I am sure there must be a better way to accomplish this, but this way separates it out which is important because each job role might have different employees with different job rates. So what I need is a way to for lack of a better term "re-group" them after getting to this point in either mysql or php OR if you have suggestion on how to just do the query better too, that'd be just fine with me. I tried to find this but I couldn't quite come across an answer that would fit this situation. Thanks in advance for the help.</p>