|
|
|
|
|
|
|
Re: like GROUP_CONCAT in Oracle [message #312675 is a reply to message #312551] |
Wed, 09 April 2008 10:34   |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
There is a built-in function in 11g (wm_concat) but it is undocumented and therefore unsupported, so results are not guaranteed and it may not be available in future versions.
SCOTT@orcl_11g> desc wm_concat
FUNCTION wm_concat RETURNS VARCHAR2
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
P1 VARCHAR2 IN
SCOTT@orcl_11g> select deptno, wm_concat (ename) as enames from emp group by deptno
2 /
DEPTNO ENAMES
---------- ---------------------------------------------
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD
SCOTT@orcl_11g>
|
|
|
Re: like GROUP_CONCAT in Oracle [message #312680 is a reply to message #312551] |
Wed, 09 April 2008 10:41  |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
There is also the documneted collect function:
SCOTT@orcl_11g> create or replace type names as table of varchar2 (255);
2 /
Type created.
SCOTT@orcl_11g> select deptno, cast (collect (ename) as names) as enames from emp group by deptno
2 /
DEPTNO ENAMES
---------- --------------------------------------------------------------------------------
10 NAMES('CLARK', 'KING', 'MILLER')
20 NAMES('SMITH', 'FORD', 'ADAMS', 'SCOTT', 'JONES')
30 NAMES('ALLEN', 'BLAKE', 'MARTIN', 'TURNER', 'JAMES', 'WARD')
SCOTT@orcl_11g>
|
|
|