select * from xm_menu res left join xm_iteration i on res.iteration_id=i.id
select (select sum(1) from xm_menu m where m.pmenu_id=res.menu_id ) as children_cnt,res.* from xm_menu res left join xm_iteration i on res.iteration_id=i.id
select (select sum(1) from xm_task t where t.parent_taskid=res.id) as children_cnt, res.*,pa.proc_inst_id,pa.assignee,pa.assignee_name,pa.main_title,pa.flow_branch_id,pa.task_name,pa.agree,pa.flow_last_time,pa.comment_msg,pa.proc_def_id,pa.flow_state
from xm_task res left join xm_task_process_approva pa on res.id=pa.xm_task_id and res.biz_proc_inst_id=pa.proc_inst_id