select select task.PROCINST_ piID from jbpm_taskinstance task,jbpm_processinstance pi
where pi.END_ !='' and pi.ID_=task.PROCINST_
and not exists (SELECT 1 from jbpm_taskinstance where end_<task.END_ and PROCINST_ =task.PROCINST_)
and task.ACTORID_='admin';
where pi.END_ !='' and pi.ID_=task.PROCINST_
and not exists (SELECT 1 from jbpm_taskinstance where end_<task.END_ and PROCINST_ =task.PROCINST_)
and task.ACTORID_='admin';