Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting count of occurances of a string in a column value

102480Nov 7 2007 — edited Feb 25 2011
Hi,
Is there a way to get the number of occurences of a string in a single column value?

Example:

CREATE TABLE STRING_CNT(X VARCHAR2(100));

INSERT INTO STRING_CNT(X) VALUES('OracleXXOracleXXOracleXXOracle');

Commit;


Now the string 'Oracle' is repeated 4 times in the inserted value. I would like to get this count using SQL.Can some one tell me how to get this?

I was asked this interesting question in an interview today.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2011
Added on Nov 7 2007
18 comments
23,263 views