如何分别计算每个员工的总人数,男性总人数,女性总人数? 我有两张桌子。一个是员工,第二个是任命。
员工表:
Employee_ID Employee_Designation Gender
1 HR Male
2 HR Female
3 Admin Male
4 Admin Male
5 Manager Female
名称表:
Designation_ID Designation_Name
1 HR
2 Admin
3 Manager
4 Developer
我要跟踪刀片模板中的输出。
Designation Total_Employee Total_Male TOtal_Female
HR 2 1 1
Admin 2 2 0
Manager 1 0 1
我在控制器中的代码仅适用于全部员工。
$caste_data = DB::table('employee')->select('designation.designation_name',
DB::raw('count(*) as total'))->leftjoin('designation'
,'designation.designation_id','=',
'employee.employee_designation')->groupBy('designation')->get();
如何分别计算每个员工的总人数,男性总人数,女性总人数