其中有EMP_POST_EMPLOYEE表为员工任职表,POST_INFO为职位信息表,一个员工多个任职,任职分主任职和兼职,IS_PRIMARY为是否兼职,我这里排序是为了主任职的排前面,
select listagg(post_name,' 兼职:') within group ( order by IS_PRIMARY desc nulls last ,post_level desc nulls last ) as name from (select EMPLOYEE_ID,post_name,IS_PRIMARY,p.post_level from EMP_POST_EMPLOYEE e LEFT JOIN POST_INFO p on e.post_id=p.ID where post_name is not null and EMPLOYEE_ID='MIS79287' ) e GROUP BY EMPLOYEE_ID;
运行结果为