Oracle SQL tips and tricks + Unix/Linux Work Log
See how much a single Oracle SQL statement can do... Plus some Unix/Linux Work Log
Sunday, February 12, 2006
Count String Occurance
(length(str1) - length(replace(str1, str2)))/length(str2)
gives how many times str2 appears in str1.
e.g.
select (length('xyzabc123abcefgh') - length(replace('xyzabc123abcefgh', 'abc')))/length('abc') from dual
OCCURANCE
----------
2
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment