问题
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