时间:2021-07-01 10:21:17 帮助过:3人阅读
结果:
1 分析及投后管理
2 财务部
3 财务部
4 管理中心
2、列拼接成行 wm_concat()
select replace(wm_concat(zxdept), ‘,‘, ‘/‘) as 部门名称 from (select zxdept from (select d.id, d.zxdept, d.RANK, d.fatherId from web_dept d start with d.id = 18022--获取18022部门层级 and d.SHOWFLAG = 1--可用 connect by PRIOR fatherId = id) temp where temp.rank <= 4--四级以内 and temp.rank >= 1--大于等于一级 order by rank asc)
结果:管理中心/财务部/财务部/分析及投后管理
3、获取最新分组内所有一条记录
select * from ( --以 orderno 分组,查找分组内最新一条工作流日志 select t.*, row_number() over(partition by orderno order by FORTIME desc) rn from (select * from WORKFLOW_INSTANCE_LOG where orderno in (select to_char(ID) as id from HR_DIMISSION where USERCODE = ‘B143130‘ and (FLAGSAVE = 2 or FLAGSAVE = 9) -- 离职单 union all select to_char(ID) as id from HR_ConFirm where USERCODE = ‘B143130‘ and FLAGSAVE = 2 -- 转正单 union all select to_char(ID) as id from HR_Transposal where USERCODE = ‘B143130‘ and FLAGSAVE = 2 -- 调岗单 )) t) where rn = 1
Oracle 方法
标签: