首页 » ORACLE 9i-23c » sql 计算字符在字符串出现了次数

sql 计算字符在字符串出现了次数

如何用sql  计算在一个字符串中某个字符出现了几次,如 ‘12341211’可的逗号出现了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

打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. Clarissa Connors | #1
    2011-12-21 at 04:08

    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.