Just don't understand why i'd have to aggregrate every single table column just for SQL SERVER to look the other way. It's difficult to understand. Why should i do the following:
$this->db->select("MAX(c.id),MAX(c.name),MAX(c.phone)");
$this->db->select('MAX(state.name) as st_nm');
$this->db->select('MAX(lga.name) as "lga_nm"');
$this->db->select('MAX(cp2.point_name),MAX(cp2.location)');
$this->db->select('SUM(pr.amount) as "amt"');
$this->db->from('consultant as c');
$this->db->join('state','state.id=c.state','inner');
$this->db->join('lga','lga.id=c.lga','inner');
$this->db->join('collection_point2 as cp2','cp2.point_code=c.collection_point','inner');
$this->db->join('payment_records as pr','pr.consultant_id=c.unique_id','inner');
$this->db->where('c.agent_id',$agent);
$this->db->group_by('c.id');
$this->db->order_by('c.id');
Just to avoid this:
Msg 8120, Level 16, State 1, Line 1 Column ... is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.