select
	 bu.realname as name
	,bu.id as id
	,count(*) as taskTotal
	,SUM(CASE WHEN hi.END_TIME_ is not null THEN 1 ELSE 0 END) AS finishTotal
	,SUM(CASE WHEN hi.END_TIME_ is null  THEN 1 ELSE 0 END) AS noFinishTaskTotal
	,SUM(CASE WHEN hi.START_TIME_<ifnull(hi.END_TIME_,now()) +INTERVAL 0-:tookTime day THEN 1 ELSE 0 END) AS overdueCount
from
	ACT_HI_TASKINST hi
	inner join t_s_base_user bu on hi.ASSIGNEE_=bu.username
	inner join t_s_user_org org on org.user_id=bu.ID and ifpluralism='0' and org.status='0'
where org.org_id = :entityParam.pid
<#if (entityParam.attType)??>
	and hi.START_TIME_ between :entityParam.attStartTime and :entityParam.attEndTime
</#if>

group by bu.ID
order by taskTotal asc