[英]How to calculate the number of occurrences of a character in a varchar in a single SQL?
Say there is a variable 假设有一个变量
v_Source := 'stack#over#flo#w';
How to get the number of occurrences of ' #
' in it in a single SQL query? 如何在单个SQL查询中获取“
#
”的出现次数?
select length('stack#over#flo#w') - length(replace('stack#over#flo#w','#',null))
from dual;
From oracle 11 you can use REGEXP_COUNT 从oracle 11开始,您可以使用REGEXP_COUNT
select REGEXP_COUNT('stack#over#flo#w', '#') from dual;
SELECT REGEXP_COUNT( 'stack#over#flo#w', '#' )
FROM DUAL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.