设有SUM_STR()这样一个类似SUM()的聚合函数,功能如:
select sum_str(name,',')from class group by type;
可以把name用‘,’连接按type分组查出来。
有这样的聚合函数不?还有聚合函数是否可以自定义?
--by zhengyun
select sum_str(name,',')from class group by type;
可以把name用‘,’连接按type分组查出来。
有这样的聚合函数不?还有聚合函数是否可以自定义?
--by zhengyun
不过10g不能用。
10g的话,可以用connect by来做,例子select t.code,substr(max(sys_connect_by_path(t.sz,',')),2) sz
from
(select code,sz,row_number()over(partition by code order by sz) rn from (select * from prdsz where rownum<100)) t
start with t.rn=1
connect by t.code=prior t.code
and t.rn-1=prior t.rn
group by t.code;
wm_concat(列名)
这个函数不能指定分隔符,只能以逗号分隔oracle可以自定义聚合函数