输入 enter image description here
输出 enter image description here
选择deptno,替换(标题,' d','作者),来自员工的日期
对于特定的离开我有多个标题和日期,所以我想以行方式显示
答案 0 :(得分:0)
您的数据与您想要的结果不符。以下是我认为你想要的东西:
create table deleteme_tbl(department int, title varchar2(20), mydate date);
insert into deleteme_tbl values( 1,'One', date '2016-01-01');
insert into deleteme_tbl values( 1,'Two', date '2016-04-01');
insert into deleteme_tbl values( 1,'three', date '2016-02-02');
insert into deleteme_tbl values( 2,'five', date '2016-04-04');
insert into deleteme_tbl values( 2,'six', null);
insert into deleteme_tbl values( 2,'seven', null);
commit;
SELECT department
, LISTAGG (title, ',') WITHIN GROUP (ORDER BY title) titles
, LISTAGG (mydate, ',') WITHIN GROUP (ORDER BY mydate) mydates
FROM deleteme_tbl
GROUP BY department;
DEPARTMENT TITLES MYDATES
1 One,Two,three 01-JAN-16,02-FEB-16,01-APR-16
2 five,seven,six 04-APR-16