Re: find out how many times particular character occur in given string.
Date: Wed, 10 Dec 2008 05:57:16 -0800 (PST)
Message-ID: <55b2bc5f-a50a-4aa4-8fbc-64507d23788c@d42g2000prb.googlegroups.com>
On Dec 10, 8:19 am, Sanjeev <sanjeev.atvan..._at_gmail.com> wrote:
> Dear Gurus,
>
> I want to find out how many times particular character occur in
> given string.
> e.g. 'A*B*C*D*E*F' count of '*' is 5
> 'A*B*C*D' count of '*' is 3
> 'A' count of '*' is 0
>
> Is there any function available in SQL to find out the above
> requirement ?
>
> Could anyone help me in above?
>
> Thanking in advance
> Sanjeev
I am not in front of a computer with Oracle on it so I cannot post working SQL but look up the following functions: instr, length, translate, and the regular expressions functions: regexp*.
One method would be to translate all characters except the one(s) you are interested in counting to null and then take the length of the remaining value.
HTH -- Mark D Powell -- Received on Wed Dec 10 2008 - 07:57:16 CST