select name from people,我想把name的值全部相加得到一个结果,自定义的函数该怎么写,求大神指教
你的意思是想把所有的name的值加到一块?Oracle有自带的方法,wm_concat
select wm_concat(name) from people
结果是这样的:1,2,3,4,5,6
中间以逗号分隔。
那如果我不想他们以逗号隔开,就123456,该怎么做?
@qjm201000:repleace一下就行了。
select wmsys.wm_concat(name) OneName from people
SQL> select listagg(name,',') within group (order by gid) names from people;
NAMES
--------------------------------------------------------------------------------
H k o n g, J a c k, S h e n Z h e n
SQL> select listagg(name,'') within group (order by gid) names from people;
NAMES
--------------------------------------------------------------------------------
H k o n g J a c k S h e n Z h e n