以人为维度,找出每个人的已办记录
思路分析:每个流程可能一个人已办过多次,我们只需要取其中一次的已办记录(如果需要取处理时间,则取最后一次已办记录,最后一次已办记录=办理日期+时间最大的那一条),每个流程有多个已办,每个流程参与过的人,均有一条已办记录
select row_number() OVER(ORDER BY b.requestid) AS id,--数据ID
b.requestid, --流程ID
a.requestmark, --流程编号
b.workflowid, --流程ID
a.creater, --创建人
a.createdate, --创建日期
d.departmentid, --部门
b.userid, --处理人
c.dclr --待处理人
from (select distinct requestid, userid, workflowid
from workflow_currentoperator
where isremark in ('2', '4')) b --所有流程已办
left join workflow_requestbase a
on b.requestid = a.requestid
left join hrmresource d
on a.creater = d.id
left join view_dclrforallflow c --所有流程的待处理人
on b.requestid = c.requestid
where b.requestid = 39347--查询条件写在最后
本文介绍了一种通过SQL查询特定人员在各个流程中的已办记录的方法。该查询关注于选取每个人在每个流程中的一次已办记录,如果需要考虑处理时间,则选择最后一次已办记录进行展示。

被折叠的 条评论
为什么被折叠?



