首页 > 数据库 > Oracle > oracle 统计字符串出现的次数
用select (length(str1) - length(replace(str1, str2)))/length(str2) from dual;应该能给出str2在str1中出现的次数。
例如:
select (length('xyzabc123abcdefgh') -
length(replace('xyzabc123abcdefgh', 'abc')))/length('cde') from dual;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31369373/viewspace-2123031/ ,如需转载,请注明出处,否则将追究法律责任。