Ето ви:-
$query = $this->db->query('SELECT city, COUNT(city) AS jobcount FROM `jobs` GROUP BY city ORDER BY jobcount DESC');
if ($query->num_rows() > 0)
foreach ($query->result() as $row)
$data[] = array(
'total' => $row->jobcount,
'city' => $row->city
);
return $data;
Не забравяйте да размените 'jobs'
с името на вашата таблица