如何在下面的 $query 中添加 select COUNT 和 DISTINCT?如果您需要任何其他详细信息来解决此问题,请告诉我。感谢您的时间。
if(isset($_POST["intake_year"]))
{
$query = "
SELECT * FROM marketing_data
WHERE intake_year = '".$_POST["intake_year"]."'
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$output[] = array(
'semester' => $row["semester"],
'student_matric' => floatval($row["count"])
);
}
echo json_encode($output);
}
//SELECT count(student_matric) AS count, semester, intake_year FROM marketing_data GROUP BY intake_year - 此查询仅用于 COUNT student_matric
//SELECT DISTINCT semester FROM marketing_data ORDER BY semester DESC - 此查询仅针对 DISTINCT 学期
蛊毒传说