select
sub.certificate_name as `name`,count(*) c
from
 t_bus_user_certificate  cert
 ,t_bus_certificate_subsidy sub
 ,t_s_base_user u
 ,t_s_user_org org
 ,t_bus_user_personnel pers
 ,t_s_depart dep
 where cert.certificateid = sub.id
 and cert.userid=u.id
 and cert.userid=org.user_id
 and u.id=org.user_id
 and u.id = pers.userid
 and dep.id=org.org_id
 and pers.leave_date is null and u.delete_flag = '0'
 and cert.delete_flag<>1
 and (dep.id = :depid or dep.parentdepartid=:depid)
 and cert.certificateid in(
	select cert2.certificateid from t_bus_user_certificate cert2 where cert2.userid=:userid
 )
 group by sub.certificate_name

