I want to calculate the average of a specific column (rating).
rating
My coding attempt is giving me a syntax error in the query.
$this->db->select('*, AVG(`rating`) As avg_r');
Try this:
$this->db->select('id, name, email, AVG(rating) as avg_r');