我要除以这两个计数,然后在表['final_count']中回显除法的结果。有人可以帮我解决我要去的地方...
=SUMPRODUCT(COUNTIFS(WP2C_Employee_Name,Project_Managers,WP2C_Employee_Task,Tasks[WP2C Implementation]))
答案 0 :(得分:1)
如果您只想显示它:
{
echo "<tr>";
echo "<td class='text-center'>".($testrow['win_count']/$testrow['bet_count']). "</td>";
echo "</tr>";
}
尽管我也会改善您的SQL查询:
$testsql="
SELECT
COUNT(*) AS bet_count,
SUM(IF(result = $Win, 1, 0)) AS win_count,
FROM test WHERE betDate = $Date
";
另一方面,如果您想学习使用MySQL和PHP,我强烈建议您学习PDO而不是mysqli。即使它看起来更复杂-它也会教您面向对象编程的基础知识以及与MySQL工作相关的一些良好习惯,例如参数(下面的示例中的问号)。
例如,您在PDO中的查询为
$sql = "
SELECT
COUNT(*) AS bet_count,
SUM(IF(result = ?, 1, 0)) AS win_count,
FROM test WHERE betDate = ?
";
$sth = $dbh->prepare($sql);
$sth->execute([$Win, $Date]);
$results = $sth->fetchAll();