【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--

posted @ 2021-09-07 17:49  逆火狂飙  阅读(1506)  评论(0)    收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东