select count(baseuu.realname) as total, 
count(uu2.id)as querycount, 
cast(count(uu2.id)/count(baseuu.realname) as decimal(10,2)) as percent,
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_s_user uu2 on baseuu.id = uu2.id 
<#if inDto.minBirth ?exists && inDto.minBirth ?length gt 0>
	AND STR_TO_DATE(SUBSTRING(uu2.idcard,7,8),'%Y%m%D') >= :inDto.minBirth 
</#if>

<#if inDto.maxBirth ?exists && inDto.maxBirth ?length gt 0>
	AND STR_TO_DATE(SUBSTRING(uu2.idcard,7,8),'%Y%m%D') <= :inDto.maxBirth 
</#if>
where  pers.leave_date is null and baseuu.delete_flag = '0' and dp.glcname is not null
GROUP BY dp.glcname
