SELECT c1, SUBSTR (MAX (SYS_CONNECT_BY_PATH (c2, ',')), 2) NAME
FROM (SELECT c1, c2, rn, LEAD (rn) OVER (PARTITION BY c1 ORDER BY rn) rn1
FROM (SELECT c1, c2, ROW_NUMBER () OVER (ORDER BY c2) rn
FROM (select b.id c1,a.id c2 from hrm_emp.hrm_sys_base_code_t a,hrm_emp.hrm_sys_code_type_t b
where a.code_type_id=b.id
and a.code_type_id=7)))
START WITH rn1 IS NULL
CONNECT BY rn1 = PRIOR rn
GROUP BY c1;
select b.id c1,a.id c2 from hrm_emp.hrm_sys_base_code_t a,hrm_emp.hrm_sys_code_type_t b
where a.code_type_id=b.id
and a.code_type_id=7 可灵活切换
网友评论