arp.name_ as processDefinitionName, arv_businessKey.text_ as businessKey, arp.version_,
arv_businessTitle.text_ as businessTitle, arv_businessDetailsPath.text_ as businessDetailsPath,
su.nickname as applyUser, arv_applyUserId.text_ as _applyUserId
from act_ru_task art
inner join act_ru_identitylink ari on ari.task_id_ = art.id_
left join act_re_procdef arp on art.proc_def_id_ = arp.id_
left join act_ru_variable arv_businessKey on arv_businessKey.execution_id_ = art.execution_id_ and arv_businessKey.name_ = 'businessKey'
left join act_ru_variable arv_businessTitle on arv_businessTitle.execution_id_ = art.execution_id_ and arv_businessTitle.name_ = 'businessTitle'
left join act_ru_variable arv_businessDetailsPath on arv_businessDetailsPath.execution_id_ = art.execution_id_ and arv_businessDetailsPath.name_ = 'businessDetailsPath'
left join act_ru_variable arv_applyUserId on arv_applyUserId.execution_id_ = art.execution_id_ and arv_applyUserId.name_ = 'applyUserId'
left join sys_user su on su.id = arv_applyUserId.text_
-- select distinct
-- art.id_, art.rev_, art.execution_id_, art.proc_inst_id_ as process_instance_id, art.proc_def_id_ as process_definition_id, art.name_,
-- art.parent_task_id_, art.description_, art.task_def_key_ as task_definition_key, art.owner_, art.assignee_, art.delegation_, art.priority_,
-- arp.name_ as processDefinitionName, arv_businessKey.text_ as businessKey, arp.version_,
-- arv_businessTitle.text_ as businessTitle, arv_businessDetailsPath.text_ as businessDetailsPath,
-- su.nickname as applyUser, arv_applyUserId.text_ as _applyUserId
-- from act_ru_task art
-- inner join act_ru_identitylink ari on ari.task_id_ = art.id_
-- left join act_re_procdef arp on art.proc_def_id_ = arp.id_
-- left join act_ru_variable arv_businessKey on arv_businessKey.execution_id_ = art.execution_id_ and arv_businessKey.name_ = 'businessKey'
-- left join act_ru_variable arv_businessTitle on arv_businessTitle.execution_id_ = art.execution_id_ and arv_businessTitle.name_ = 'businessTitle'
-- left join act_ru_variable arv_businessDetailsPath on arv_businessDetailsPath.execution_id_ = art.execution_id_ and arv_businessDetailsPath.name_ = 'businessDetailsPath'
-- left join act_ru_variable arv_applyUserId on arv_applyUserId.execution_id_ = art.execution_id_ and arv_applyUserId.name_ = 'applyUserId'
-- left join sys_user su on su.id = arv_applyUserId.text_
SELECT
MAX(art.id_) AS id_,
MAX(art.rev_) AS rev_,
MAX(art.execution_id_) AS execution_id_,
art.proc_inst_id_ AS process_instance_id,
MAX(art.proc_def_id_) AS process_definition_id,
art.name_,
MAX(art.parent_task_id_) AS parent_task_id_,
MAX(art.description_) AS description_,
MAX(art.task_def_key_) AS task_definition_key,
MAX(art.owner_) AS owner_,
MAX(art.assignee_) AS assignee_,
MAX(art.delegation_) AS delegation_,
MAX(art.priority_) AS priority_,
MAX(art.create_time_) AS create_time_,
MAX(art.due_date_) AS due_date_,
MAX(art.category_) AS category_,
MAX(art.suspension_state_) AS suspension_state_,
MAX(art.tenant_id_) AS tenant_id_,
MAX(art.form_key_) AS form_key_,
MAX(arp.name_) AS processDefinitionName,
MAX(arv_businessKey.text_) AS businessKey,
MAX(arp.version_) AS version_,
MAX(arv_businessTitle.text_) AS businessTitle,
MAX(arv_businessDetailsPath.text_) AS businessDetailsPath,
MAX(su.nickname) AS applyUser,
MAX(arv_applyUserId.text_) AS _applyUserId
FROM act_ru_task art
INNER JOIN act_ru_identitylink ari ON ari.task_id_ = art.id_
LEFT JOIN act_re_procdef arp ON art.proc_def_id_ = arp.id_
LEFT JOIN act_ru_variable arv_businessKey ON arv_businessKey.execution_id_ = art.execution_id_ AND arv_businessKey.name_ = 'businessKey'
LEFT JOIN act_ru_variable arv_businessTitle ON arv_businessTitle.execution_id_ = art.execution_id_ AND arv_businessTitle.name_ = 'businessTitle'
LEFT JOIN act_ru_variable arv_businessDetailsPath ON arv_businessDetailsPath.execution_id_ = art.execution_id_ AND arv_businessDetailsPath.name_ = 'businessDetailsPath'
LEFT JOIN act_ru_variable arv_applyUserId ON arv_applyUserId.execution_id_ = art.execution_id_ AND arv_applyUserId.name_ = 'applyUserId'
LEFT JOIN sys_user su ON su.id = arv_applyUserId.text_