Oracle listagg() WITHIN GROUP () 将多行合并成一行

1. 基本数据

SELECT * FROM emp WHERE deptno='10'


2. 使用 listagg() WITHIN GROUP () 将多行合并成一行

SELECT deptno, listagg(ename, ',') WITHIN GROUP(ORDER BY ename) names
  FROM emp
 WHERE deptno = '10'
 GROUP BY deptno

posted @ 2020-02-06 17:21  LuckyZLi  阅读(212)  评论(0编辑  收藏  举报