【发布时间】:2020-12-17 16:38:09
【问题描述】:
我正在尝试显示班级的最高平均分;但是,我一直在与查询作斗争几个小时,似乎无法让它工作。
我可以获得要显示的学生平均成绩列表,其中:
public function GetSumAvgftScore($student_id, $session_id, $section_id, $class_id)
{
$this->db->select_avg('ft_tot_score');
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
$this->db->where('section_id', $section_id);
$this->db->where('class_id', $class_id);
return $this->db->get('ftscores_primary')->row();
}
但是,当我尝试显示最高平均分时,我遇到了困难。这是我尝试过的:
public function GetHighestClassAvg($student_id, $session_id, $section_id, $class_id)
{
$this->db->order_by('ft_tot_score', 'DESC');
$this->db->select_max(avg('ft_tot_score'));
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
$this->db->where('section_id', $section_id);
$this->db->where('class_id', $class_id);
$data = $this->db->get('ftscores_primary')->row();
}
这并没有给我任何东西。
【问题讨论】:
-
这个
$this->db->where('student_id', $session_id);是您的问题中的拼写错误还是您的问题的可能原因? -
我已经纠正了,现在我得到了错误
Message: Call to undefined function avg()
标签: php mysql codeigniter