分享一个汇报关系的SQL语句原创
金蝶云社区-boolean
boolean
9人赞赏了该文章 341次浏览 未经作者许可,禁止转载编辑于2021年03月10日 18:19:13

适用于使用主要任职作为流程直接上级的用户。

解决设置职位后,无法直观看出汇报关系。


祭出大杀器:

sql语句,可以向上查询到三级:


select tbdp.FNUMBER as 员工编码,tbdp.FNAME_l2 as 员工姓名,top.FNAME_l2 as 职位名称,top1.FNAME_l2 as 直接上级岗位 ,tbdp1.fname_l2 as 直接上级姓名, top2.FNAME_l2 as 二级上级岗位,tbdp2.fname_l2 as 二级上级姓名, top3.fname_l2 as 三级上级岗位,tbdp3.fname_l2 as 三级上级姓名, tobe.FDISPLAYNAME_l2  as 组织信息,tbdp.FDELETEDSTATUS as 状态  from T_HR_PersonPosition thrp

LEFT OUTER JOIN T_bd_person tbdp ON THRP.FPERSONID = TBDP.FID

LEFT OUTER JOIN T_ORG_POSITION top ON THRP.FPRIMARYPOSITIONID = TOP.FID

LEFT OUTER JOIN T_ORG_BASEUNIT tobe ON thrp.FPERSONDEP  = tobe.FID 

LEFT OUTER JOIN T_ORG_POSITION top1 on top.FPARENTID = top1.fid

LEFT OUTER JOIN T_ORG_PositionMember topm1 on topm1.FPOSITIONID = top1.fid

LEFT OUTER JOIN T_bd_person tbdp1 on tbdp1.fid = topm1.FPERSONID 

LEFT OUTER JOIN T_ORG_POSITION top2 on top1.FPARENTID = top2.fid

LEFT OUTER JOIN T_ORG_PositionMember topm2 on topm2.FPOSITIONID = top2.fid

LEFT OUTER JOIN T_bd_person tbdp2 on tbdp2.fid = topm2.FPERSONID 

LEFT OUTER JOIN T_ORG_POSITION top3 on top2.FPARENTID = top3.fid

LEFT OUTER JOIN T_ORG_PositionMember topm3 on topm3.FPOSITIONID = top3.fid

LEFT OUTER JOIN T_bd_person tbdp3 on tbdp3.fid = topm3.FPERSONID 


图标赞 9
9人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!