在11G以下版本中oracle有自带的函数wm_concat可以实现,如:

select wm_concat(id) from table where col='1'

 但是在12C版本中此函数无法使用,但可以使用另一种方式实现,如:

select xmlagg(xmlparse(content upper(id)||',' wellformed) order by id).getclobval() from table where col='1' 

 该函数返回结果为一个Blob类型的大字段,且因为使用逗号拼接的关系,在结尾会多一个逗号,转换为字符串后会默认全部大写,如不需要大写可以自己修改函数或转换。

 
posted on 2019-10-21 16:38  车车12138  阅读(6258)  评论(1编辑  收藏  举报