Wednesday, May 11, 2016

How to find number of words in the string


By using length function it is possible to find number of words in the sentence.  First, we find the length of the string and length of the same string without spaces. The difference between them plus 1 will be the number of words in the sentence.


SELECT LENGTH('Oracle PL SQL') - LENGTH(REPLACE('Oracle PL SQL', ' ', '')) + 1 WordCount

from DUAL

No comments:

Post a Comment