如何在下面的 $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 学期
1 回答
蛊毒传说
TA贡献1895条经验 获得超3个赞
我想你正在寻找类似的东西
$query = "
SELECT distinct semester , count(student_matric) as count FROM marketing_data
WHERE intake_year = '".$_POST["intake_year"]."'
Group by student_matric " ;
- 1 回答
- 0 关注
- 143 浏览
添加回答
举报
0/150
提交
取消