Is this possible in (Oracle) SQL?
I have a varchar for example "This is varchar" and I want to count number of "i" (it's 2)...
Is this possible in (Oracle) SQL?
I have a varchar for example "This is varchar" and I want to count number of "i" (it's 2)...
Try to use REGEXP_COUNT
function as below:
select REGEXP_COUNT( 'This is varchar', 'i' ) from dual
Here you can find more information about REGEXP_COUNT.
You could remove all of the i
s and check the length difference.
select length('This is varchar')
- NVL(length(replace('This is varchar', 'i')) , 0)
from dual;
Try this:
LENGTH(varcharString) - LENGTH(REPLACE(varcharString, 'i', ''))