日期:2014-05-18 浏览次数:20569 次
select a.FLOW_ID, a.FLOW_VER , a.FLOW_NAME, f.STEP_ID, f.STEP_NAME, e.NODE_KEY, STU.TRACK_RULE_ID, STU.TRACK_RULE_NAME from SBRM_FLOW a left join SBRM_FLOW_NODE_PATH c on c.DIA_KEY = a.DIA_KEY left join SBRM_FLOW_NODES e on e.NODE_KEY = c.FROM_NODE_KEY left join SBRM_STEP f on f.STEP_KEY = e.STEP_KEY left JOIN SBRM_STEP_TRACK_RULE SSTR ON f.STEP_KEY = SSTR.STEP_KEY left JOIN SBRM_TRACK_RULE STU ON STU.TRACK_RULE_KEY = SSTR.TRACK_RULE_KEY where a.FLOW_ID = 'F-3P4O1U' AND NOT EXISTS(SELECT 1 FROM SBRM_FLOW WHERE FLOW_ID=a.FLOW_ID AND FLOW_VER>a.FLOW_VER) order by flow_id, NODE_KEY DESC
------解决方案--------------------
select a.FLOW_ID, a.FLOW_VER as FLOW_VER, a.FLOW_NAME, f.STEP_ID, f.STEP_NAME, e.NODE_KEY, STU.TRACK_RULE_ID, STU.TRACK_RULE_NAME from SBRM_FLOW a left join SBRM_FLOW_NODE_PATH c on c.DIA_KEY = a.DIA_KEY left join SBRM_FLOW_NODES e on e.NODE_KEY = c.FROM_NODE_KEY left join SBRM_STEP f on f.STEP_KEY = e.STEP_KEY left JOIN SBRM_STEP_TRACK_RULE SSTR ON f.STEP_KEY = SSTR.STEP_KEY left JOIN SBRM_TRACK_RULE STU ON STU.TRACK_RULE_KEY = SSTR.TRACK_RULE_KEY where a.FLOW_ID = 'F-3P4O1U' and a.FLOW_VER= (select max(FLOW_VER) lastFLOW_VER from SBRM_FLOW a2 where a.FLOW_ID=a2.FLOW_ID) order by flow_id, NODE_KEY desc