# Re: find out how many times particular character occur in given string.

Date: Thu, 11 Dec 2008 22:37:18 +1100

Message-ID: <ghqtsu$ocg$1@news.motzarella.org>

Michel Cadot wrote,on my timestamp of 11/12/2008 3:34 AM:

*> "Sanjeev" <sanjeev.atvankar_at_gmail.com> a écrit dans le message de news: *

*> 6e2ea0b9-5782-4945-962c-5c7de86dde9b_at_k36g2000pri.googlegroups.com...*

*> | 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*

*> *

*> SQL> def str='A*B*C*D*E*F'*

*> SQL> def car='*'*

*> SQL> select length('&str')-length(replace('&str','&car')) nb from dual;*

*> NB*

*> ----------*

*> 5*

*> *

*> 1 row selected.*

*> *

*> SQL> def str='A*B*C*D'*

*> SQL> /*

*> NB*

*> ----------*

*> 3*

*> *

*> 1 row selected.*

*> *

*> SQL> def str='A'*

*> SQL> /*

*> NB*

*> ----------*

*> 0*

*> *

*> 1 row selected.*

**BINGO!
**
:)
Received on Thu Dec 11 2008 - 05:37:18 CST