Код: Выделить всё
public function read_sum_groupby($table, $column,$groupBy,$where=array()){
$this->db->group_by($groupBy);
$this->db->where($where);
$this->db->select_sum($column);
$result = $this->db->get($table);
return $result->result();
}
Код: Выделить всё
$installment_discount = $this->action->read_sum_groupby("installment","discount","installment_id",array("loan_id"=>$loan->id));
Код: Выделить всё

вы можете видеть, что последнее значение равно 800, но мое ожидаемое значение было 200.
моя таблица была

Подробнее здесь: https://stackoverflow.com/questions/435 ... p-bygroupb
Мобильная версия