Oracle: counting the number of substrings in a string?
2 answers
Before 11g, you can:
select (length(string) - length(replace(string,substring,''))) / length(substring) as occ
from dual;
The idea is to see how much space in a string is occupied by a substring, and then to see how many times the substring is in that space, simply divide it by the length of the substring.
+1
source to share