create table emp(
emp_id number primary key,
emp varchar2(10),
emp_date date,
deptno number
)
Insert into emp (emp_id, emp,emp_date,deptno) values (1,'Ronaldo','01.01.2021.',1);
Insert into emp (emp_id, emp,emp_date,deptno) values (2,'Ronaldo','02.01.2021.',1);
Insert into emp (emp_id, emp,emp_date,deptno) values (3,'Ronaldo','03.01.2021.',1);
Insert into emp (emp_id, emp,emp_date,deptno) values (4,'Messi','01.01.2021.',1);
Insert into emp (emp_id, emp,emp_date,deptno) values (5,'Messi','02.01.2021.',2);
Insert into emp (emp_id, emp,emp_date,deptno) values (6,'Ronaldo','04.01.2021.',2);
Insert into emp (emp_id, emp,emp_date,deptno) values (7,'Messi','04.01.2021.',2);
01.01.2021 | 02.01.2021 | 03.01.2021 | 04.01.2021
------------------------------------------------------------------------------------------
deptno 1 Ronaldo, Messi Ronaldo, Messi Ronaldo
deptno 2 null Messi null Ronaldo, Messi
需要在上表中显示结果。
1条答案
按热度按时间sd2nnvve1#
你可以试着用
listagg
与CASE WHEN
查询1:结果: