【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