here in below how you can do it
$this->db->select('r.report_id,
a.advertisement_title,
COUNT(r.advertisement_id) AS total');
$this->db->from('report r');
$this->db->join('advertisement a','a.advertisement_id = r.advertisement_id');
$this->db->group_by('r.advertisement_id');
solved How do I convert below query into codeigniter [duplicate]