Home » RDBMS Server » Server Administration » To find number of occurences of a character in a string.
To find number of occurences of a character in a string. [message #372629] Thu, 01 March 2001 05:13 Go to next message
ramu
Messages: 82
Registered: February 2001
Member
I have created a pl/sql block to find the number of occurences of a given character in a string. For example if the string is 'ramakrishnan' then the number of occurence of 'a' is 3.

Is there any way to find the answer in a single query?
Can any one tell me?
Re: To find number of occurences of a character in a string. [message #372630 is a reply to message #372629] Thu, 01 March 2001 05:51 Go to previous messageGo to next message
Joachim Lindner
Messages: 30
Registered: February 2001
Member
Try ...

select length(string)-length(replace(string,character,'')) from dual;
Re: To find number of occurences of a character in a string. [message #372632 is a reply to message #372629] Thu, 01 March 2001 06:36 Go to previous message
ramu
Messages: 82
Registered: February 2001
Member
Thanks for your query to find the number of occurences of a character in a string. I tried and got the result.
Thanks to you.
Ramu..
Previous Topic: Update query
Next Topic: Creating Views
Goto Forum:
  


Current Time: Sat Jun 29 09:16:39 CDT 2024