Not able to use LISTAGG

后端 未结 1 538
一生所求
一生所求 2021-01-29 14:36
SELECT deptno, LISTAGG(ename, \',\') WITHIN GROUP (ORDER BY ename) AS employees
FROM   emp
GROUP BY deptno;
         


        
相关标签:
1条回答
  • 2021-01-29 15:26

    In this article you have different approaches to dealing with string aggegation, including those to take into account if you are running an Oracle version prior to 11g Release 2 (which is your scenario).

    Particularly, you can use Oracle's WM_CONCAT function:

    SELECT deptno, wm_concat(ename) AS employees
    FROM   emp
    GROUP BY deptno;
    

    You can also define your own function for string aggregation or use other functions such as SYS_CONNECT_BY_PATH or COLLECT. In the above article you have examples of these methods.

    0 讨论(0)
提交回复
热议问题