【oracle】統計字段里逗號的數量,采用函數regexp(field,',')


實驗表:

create table tmp(
id int,
name nvarchar2(20),
primary key(id));

實驗數據:

insert into tmp(id,name) values(1,'an,dy');
insert into tmp(id,name) values(2,'a,n,d,y');
insert into tmp(id,name) values(3,'andy,');
insert into tmp(id,name) values(4,',Bill');

函數使用:

SQL> select regexp_count(name,',') as ct,name from tmp;

        CT NAME
---------- ----------------------------------------
         1 an,dy
         3 a,n,d,y
         1 andy,
         1 ,Bill

核心:

select regexp_count(name,',') as ct,name from tmp;

--END--


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM