有一张表:
no name text
1 a hello
2 a world
3 a haha
4 b ccc
5 b ddd
我想根据name字段,如果同名就显示:
a helloworldhaha
b ccdd
怎么用一条SQL语句(不用store procedure)来做到?
------解决方案--------------------
- SQL code
with t as(select 1 id,'a' name,'hello' text from dualunion allselect 2,'a','world' from dualunion allselect 3,'a','haha' from dualunion allselect 4,'b','ccc' from dualunion allselect 5,'b','ddd' from dual)select name,replace(wm_concat(text),',','') from t group by name;NAME REPLACE(WM_CONCAT(TEXT),',',''---- --------------------------------------------a helloworldhahab cccddd