select count(baseuu.realname) as total, 
count(uu2.id)as ruzhi, 
count(uu3.id)as lizhi, 
count(uu4.id)as diaoru, 
count(uu5.id)as diaochu, 
count(uu6.id)as jiediaoru, 
count(uu7.id)as jiediaochu, 
count(uu8.id)as jinsheng, 
count(uu9.id)as jiangzhi, 
count(uu10.id)as neibupeixun, 
count(uu11.id)as waibupeixun, 
count(uu12.id)as neibujiajiang, 
count(uu13.id)as yezhubaojiang, 
count(uu14.id)as neibuchufa, 
count(uu15.id)as waibutousu, 
count(uu16.id)as waibuchufa, 
dp.glcname as departname
from t_bus_user_personnel pers
LEFT JOIN t_s_base_user baseuu on baseuu.id = pers.userid
left join t_s_user_org uorg on uorg.user_id = pers.userid and uorg.ifpluralism = '0'
left join t_s_user uu on baseuu.id = uu.id
left join t_s_depart dp on dp.ID = uorg.org_id
left join t_bus_user_event uu2 on baseuu.id = uu2.user_id and uu2.event_type = 'ruzhi'
left join t_bus_user_event uu3 on baseuu.id = uu3.user_id and uu3.event_type = 'lizhi'
left join t_bus_user_event uu4 on baseuu.id = uu4.user_id and uu4.event_type = 'diaoru'
left join t_bus_user_event uu5 on baseuu.id = uu5.user_id and uu5.event_type = 'diaochu'
left join t_bus_user_event uu6 on baseuu.id = uu6.user_id and uu6.event_type = 'jiediaoru'
left join t_bus_user_event uu7 on baseuu.id = uu7.user_id and uu7.event_type = 'jiediaochu'
left join t_bus_user_event uu8 on baseuu.id = uu8.user_id and uu8.event_type = 'jinsheng'
left join t_bus_user_event uu9 on baseuu.id = uu9.user_id and uu9.event_type = 'jiangzhi'
left join t_bus_user_event uu10 on baseuu.id = uu10.user_id and uu10.event_type = 'neibupeixun'
left join t_bus_user_event uu11 on baseuu.id = uu11.user_id and uu11.event_type = 'waibupeixun'
left join t_bus_user_event uu12 on baseuu.id = uu12.user_id and uu12.event_type = 'neibujiajiang'
left join t_bus_user_event uu13 on baseuu.id = uu13.user_id and uu13.event_type = 'yezhubaojiang'
left join t_bus_user_event uu14 on baseuu.id = uu14.user_id and uu14.event_type = 'neibuchufa'
left join t_bus_user_event uu15 on baseuu.id = uu15.user_id and uu15.event_type = 'waibutousu'
left join t_bus_user_event uu16 on baseuu.id = uu16.user_id and uu16.event_type = 'waibuchufa'
where  pers.leave_date is null and baseuu.delete_flag = '0' and dp.glcname is not null 
GROUP BY dp.glcname