Ula Krukar Ula Krukar - 1 year ago 113
SQL Question

How to count the number of occurrences of a character in an Oracle varchar value?

How can I count number of occurrences of the character

in a varchar2 string?


select XXX('123-345-566', '-') from dual;

Answer Source

Here you go:

select length('123-345-566') - length(replace('123-345-566','-',null)) 
from dual;