我想用totalscore / totalevaluatedcalls计算运行时间的平均值,这是100.我可以用php做到这一点......之后的表格是我的代码。在这方面我可以帮助我。总评估的电话是来自db的emp id计数。
empid agentname totalevaluatedcalls totalscore avaragescore
=========================================================================
1 xyz 2 200 100
total evaluatedcalls query
==========================
foreach($dbh->query("SELECT COUNT(*) as cnt FROM eval where empid=$empid") as $test) {
echo "<table ><tr ><td style='border: 0px; '>" . $test['cnt'] . "</td></tr></table>";
}
?>
total score query
==========================
foreach($dbh->query("SELECT SUM(totalscore) as cnt FROM eval where empid = $empid") as $leavecount) {
echo "<table ><tr ><td style='border: 0px; ' >" . $leavecount['cnt'] . "</td></tr></table>";
}
?>
答案 0 :(得分:0)
使用查询
foreach($dbh->query("select count(*) as cnt,sum(totalscore) as tot from eval where empid=$empid") as $data)
{
$avg=($data['cnt']/$data['tot'])*100;
}
答案 1 :(得分:0)
合并此查询
foreach($dbh->query("SELECT COUNT(*) as cnt, SUM(totalscore) as totalscore, SUM(totalscore)/SUM(totalevaluatedcalls) as averagescore
FROM eval
where empid= $empid
") as $test)
{
echo "<table ><tr ><td style='border: 0px; '>" . $test['cnt'] . "</td><td style='border: 0px; '>" . $test['totalscore'] . "</td><td style='border: 0px; '>" . $test['averagescore'] . "</td></tr></table>";
}