如果日期介于某个预定义日期之间,我想对列数据求和。
我这样做的核心php就像
SUM(IF(`trl`.`entrydate` between '2015-01-01' and '2015-01-31', `trl`.`itemvalue`, 0))
那我怎么能用codeigniter
来做呢答案 0 :(得分:2)
有活动记录:
$this->db->select_sum('data');
$this->db->where("entrydate between 'x' and 'y' ");
$query = $this->db->get('your table');
查询:
$this->db->query("select SUM(data) from `your table` where entrydate between 'x' and 'y' ");