SELECT * FROM task a, (SELECT id, name, addtime FROM task_step j, (SELECT id, name, max(addtime) addtime FROM task_step GROUP BY id) q WHERE j.id=q.id AND j.addtime=q.addtime) WHERE a.id=b.id