oracle regexp_replace过滤字符串中重复内容

      有时候使用listagg(id,',') within group(order by id )得到的数据里面有很多重复的数据,注意listagg中已经排过序,这是前提,如下所示

      

      可以使用regexp_replace替换掉重复的内容(数字),方便使用

       如下所示

      

select substr(regexp_replace(',&1', '(,[[:digit:]]+)(\1)+', '\1'), 2)
  from dual

    结果如下

   
oracle regexp_replace过滤字符串中重复内容_第1张图片
    
oracle regexp_replace过滤字符串中重复内容_第2张图片
       这时候在使用就很方便了

 

        全文完

 

 

你可能感兴趣的:(replace)