select length(f3) - length(replace(f3, 'a','')) from t1 简单的,如果,要统计 good 出现的次数,改成
select (length(f3) - length(replace(f3, 'good ',''))) / length('good')
from t1 -----------------------------------
SQL> select (length('XXgoodXXXXgoodxxx') -
2 length(replace('XXgoodXXXXgoodxxx', 'good', ''))) / length('good') 次数
3 from dual; 次数
----------
2