• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

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
0
pardeshirahul
Asked:
pardeshirahul
  • 2
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now