是否可以将结果组合在一起,然后将它们组合在一起?

Table Structure 1 (clockins): date | timein | timeout | jobcode | jobrate | employeeid

Table Structure 2 (jobdesc): jobcode | jobdescription

So I have a query that does:

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 < 100 /* need this to distinguish salaried employees */ 
GROUP BY `jobcode` , `employeeid`

This outputs data like:

example output

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.

I ended up getting colleagues help solving this. Just in case anyone else was looking for something similar here's how it's done in PHP:

<?php
$laborTotals = array();
$totalLaborDollars= 0;
$laborTotals[$laborAnalysis['jobcode']]['jobcode'] = $laborAnalysis['jobrole'];
    $laborTotals[$laborAnalysis['jobcode']]['jobdescription'] = $laborAnalysis['jobdescription'];
    $laborTotals[$laborAnalysis['jobcode']]['totalsalary'] += $laborAnalysis['totalsalary'];

}

foreach ($laborTotals as $labor) { 
    $html .= '  <tr>';
    $html .= '    <td class="gridData">' . $labor['jobcode'] . '</td>';
    $html .= '    <td class="gridData">' . $labor['jobdescription'] . '</td>';
    $html .= '    <td class="gridData txtLeft"><b>$</b>' . number_format($labor['totalsalary'], 2, '.', ',') . '</td>';
    $totalLaborDollars+=$labor['totalsalary'];
}

?>