如何用sql 计算在一个字符串中某个字符出现了几次,如 ‘12,34,12,11’可的逗号出现了3次,思路就是总长度减去该字符替换成空后的长度,在ORACLE 11G中出现了REGEXP_COUNT函数更加方便,
REGEXP_COUNT (source_char, pattern [, position [, match_param]])
这里我们用通用的方法length
实验开始
sql>select length(‘23,45,56,12,43,78’)-length(replace(‘23,45,56,12,43,78′,’,’,”)) from dual;
——-
5
Hello there, I would just like to say that i greatly loved looking at this weblog article. Thank you for contributing this brilliant information. You actually write extremely smoothly. Keep up the fabulous work.