I want to get the total occurrence of values in a list. See the raw Data:
In Laravel, see the code i have written but it is not correct, so i need assistance:
public static function ServiceNo($service,$fltno,$type)
{
$res = DB::table('tbname')
->select(DB::raw('count(distinct(nextSvr)) as svr'))
->where(['fltno'=>$fltno,'mtype'=>$type,'serviceType'=>$service])
->get();
foreach($res as $r){
$cnn = $r->svr;
}
return $cnn;
}
The above code, will only count the distinct nextsvr, however,what i want is better explained like this: from the above, the first three 7's are counted as 1, the next three series is 1, etc, at the end total count for service type A will be 9 services. Please, i need help in this regard.