Have a query that I'm trying to return the sum result of the columns where the value is over 10,000. I've tried adding sum(value) as total to the query but it's not working.
My code is:
$this->db->select('sum(value) as total, date, member_id');
$this->db->where('member_id', $_SESSION['sess_user_id']);
$this->db->where('cost.value >', '9999');
$this->db->where('cost.date = DATE_SUB(NOW(), INTERVAL 5 DAY)');
$query = $this->db->get('orders');
return $query->num_rows();
here's the raw SQL output:
SELECT sum(value) as total, date, member_id FROM (steps) WHERE member_id = '1' AND cost.value > '9999' AND cost.date = DATE_SUB(NOW(), INTERVAL 5 DAY)