WMSYS.WM_CONCAT 函數的用法

我们通过 10g 所提供的 WMSYS.WM_CONCAT 函数即可以完成 行转列的效果

SQL> select * from idtable;
        ID NAME
---------- ------------------------------
        10 ab
        10 bc
        10 cd
        20 hi
        20 ij
        20 mn

 SQL> select id,wmsys.wm_concat(name) name from idtable

2 group by id;
        ID NAME
---------- --------------------------------------------------------------------------------
        10 ab,bc,cd
        20 hi,ij,mn

===================

 select  t1.people,
       (select to_char(wmsys.wm_concat(real_name)) from user lu
    where instr(','||replace(t1.people,' ','')||',', ','||lu.uuid||',')>0 )  inside_people_name
from t1 
 

1 10168, 10085 a,b

2 10085, 10222, 10034 c,d,e

3 20330, 9999, 10004 f,g,h

4 10103 i

猜你喜欢

转载自ollevere.iteye.com/blog/1748891