number of words

I have a letter America
how may letter s of A we have in this
how to find it using a select statement
pardeshirahulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
The title uses "words" but the question uses "letters".  Which one do you want?

To see how many letters are in a string:  There are several ways.  Here is the one I would go with:
select length(words)-length(replace(words,'A')) from dual;

You can also do a regexp_count but for this, that is probably overkill.

If you want the number of words, we can to that as well depending on how you define a word.

If anything separated by spaces, similar replace and length check but you need to remove repeating spaces before doing it.

For words, I might look at regexp_count.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rgonzo1971Commented:
HI,

you could try
SELECT REGEXP_COUNT('America', 'A', 1, 'i') REGEXP_COUNT
   FROM DUAL;

Open in new window

or for words
SELECT REGEXP_COUNT('America,Canada;Japan.', '\b\w+\b', 1, 'i') REGEXP_COUNT
   FROM DUAL;

Open in new window

Regards
0
slightwv (䄆 Netminder) Commented:
>>or for words

That gives me a 0 on 12c.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.