日期:2014-05-16 浏览次数:21001 次
CREATE TABLE a (a1 INT, a2 VARCHAR2(1)); INSERT INTO a VALUES(1,'a'); INSERT INTO a VALUES(1,'b'); INSERT INTO a VALUES(2,'x'); INSERT INTO a VALUES(2,'y'); INSERT INTO a VALUES(2,'z'); select a1, replace(wmsys.wm_concat(a2),',','') a2 from a group by a1
------解决方案--------------------
with tb(a1,a2) as ( select 1,'a' from dual union select 1,'b' from dual union select 2,'x' from dual union select 2,'y' from dual union select 2,'z' from dual ) select a1,replace(wm_concat(a2),',') as ass from tb group by a1 / A1 ASS ---------- ---------- 1 ab 2 xzy SQL>
------解决方案--------------------
列转行问题