どうぞ:-
$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'
を交換することを忘れないでください あなたのテーブル名で