LISTAGG or WM_CONCAT in Netezza

房东的猫 提交于 2021-01-28 12:00:35

问题


Any replacement or quick solution in NETEZZA for the Oracle function LISTAGG or WM_CONCAT ?

SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employee FROM emp GROUP BY deptno;

DEPTNO EMPLOYEE

    10 JOHN,MICHEL,SAM
    20 PHILIP,FORD,SCOT,SUNNY,JOSEPH
    30 ALLEN,RUBY,BETTY,MARTIN,LEON,FRANK

Thanks.


回答1:


IBM provides a sample UDF/UDA that may meet your needs. Look for GROUP_CONCAT on this page.

The direct link to source install file is here: group_concat.tgz.

TESTDB.ADMIN(ADMIN)=> select deptno, group_concat(employee,',') from gc_test group by deptno;
 DEPTNO |            GROUP_CONCAT
--------+------------------------------------
     10 | JOHN,MICHAEL,SAM
     20 | FORD,JOSEPH,PHILIP,SCOT,SUNNY
     30 | ALLEN,BETTY,FRANK,LEON,MARTIN,RUBY
(3 rows)


来源:https://stackoverflow.com/questions/27543129/listagg-or-wm-concat-in-netezza

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!