SELECT
i.add_time,
i.id AS procInstId,
latestTask.action,
type_id,
type_name,
i.user_id,
i.user_name,
i.`status`
FROM
flow_proc_inst i
LEFT JOIN (
SELECT
maxLine.*, MAX(maxLine.step) maxStep
FROM
(SELECT DISTINCT(t1.id) tt,t1.* FROM flow_task t1 ORDER BY t1.step DESC
) maxLine
GROUP BY
maxLine.proc_inst_id
) AS latestTask ON latestTask.proc_inst_id = i.id
WHERE
i.user_id = #{c.userId}