select t1.requestid , t1.nodeid as 节点,t2.nodeid as  上一节点 ,  
t2.operatedate  as 接收日期 , t2.operatetime  as 接收时间 ,t1.operatedate as  提交日期, t1.operatetime  as  提交时间
from  workflow_requestLog  t1
left outer  join  workflow_requestLog  t2  on t1.requestid=t2.requestid     and  t1.nodeid=t2.destnodeid  and t1.LOGID>t2.LOGID 
and t2.LOGID=(select max(LOGID) from workflow_requestlog    where requestid=t1.requestid  and destnodeid  =t1.nodeid  and LOGID< t1.LOGID ) 
在oracle中执行报错

解决方案 »

  1.   

    语句上只能看出你的父节点有多个,并且你想取logid最大的。还是建议你把测试数据和规则发出来
    select *
      from workflow_requestLog t1,
           (select t1.*
              from workflow_requestLog t1
             where t1.logid = (select max(v1.logid)
                                 from workflow_requestLog v1
                                where t1.requestid = v1.requestid
                                  and t1.nodeid = v1.nodeid)) t2
     where t1.requestid = t2.requestid(+)
       and t1.nodeid = t2.destnodeid(+);
      

  2.   

    SELECT requestid , 节点,上一节点 ,  
    接收日期 ,接收时间 ,提交日期,提交时间 FROM (
    select t1.requestid , t1.nodeid as 节点,t2.nodeid as  上一节点 ,  
    t2.operatedate  as 接收日期 , t2.operatetime  as 接收时间 ,t1.operatedate as  提交日期, t1.operatetime  as  提交时间,
    MAX(T2.LOGID) OVER(PARTITION t2.requestid,t2.destnodeid) M,T2.LOGID
    from  workflow_requestLog  t1
     left  join  workflow_requestLog  t2  on t1.requestid=t2.requestid     and  t1.nodeid=t2.destnodeid  and t1.LOGID>t2.LOGID 
     ) T WHERE T.M=T.LOGID ;