使用 listagg() WITHIN GROUP () 将多行合并成一行(比较常用)
···
SELECT
T .DEPTNO,
listagg (T .ENAME, ',') WITHIN GROUP (ORDER BY T .ENAME) names
FROM
SCOTT.EMP T
WHERE
T .DEPTNO = '20'
GROUP BY
T .DEPTNO
···
效果:
image.png
使用 listagg() WITHIN GROUP () 将多行合并成一行(比较常用)
···
SELECT
T .DEPTNO,
listagg (T .ENAME, ',') WITHIN GROUP (ORDER BY T .ENAME) names
FROM
SCOTT.EMP T
WHERE
T .DEPTNO = '20'
GROUP BY
T .DEPTNO
···
效果:
本文标题:Oracle中的listagg函数和Mysql中group_co
本文链接:https://www.haomeiwen.com/subject/bsxvuhtx.html
网友评论