on 08-07-2015 9:20 AM
Hi Folks,
Can you please help me with a SQL program to display all column of a employee table where the number of vowels in FIRSTNAME AND LASTNAME is more than 5.
Regards
Nitin
One way to approach such a problem is what I just did:
select user_name,
OCCURRENCES_REGEXPR ( '[aeiou]' FLAG 'i' in user_name) as VOWEL_COUNT
from public.users;
USER_NAME | VOWEL_COUNT |
SYS | 0 |
SYSTEM | 1 |
_SYS_STATISTICS | 3 |
_SYS_EPM | 1 |
_SYS_REPO | 2 |
_SYS_AFL | 1 |
DEVDUDE | 3 |
ADMIN | 2 |
PUBLICJOE | 4 |
DEDUDE | 3 |
JDBCDUDE | 2 |
OZDUDE | 3 |
_SYS_TASK | 1 |
_SYS_XB | 0 |
From here it's trivial to come to a combined firstname/lastname vowel count.
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Goodness... working with OLD tools... alright.
How about removing all vowels from the string and checking how many characters you lost?
select user_name,
length( user_name) -
length (replace (
replace (
replace (
replace (
replace (upper(user_name)
, 'A', '')
, 'E', '')
, 'I', '')
, 'U', '')
, 'O', '')
) vowel_count_stoneage,
OCCURRENCES_REGEXPR ( '[aeiou]' FLAG 'i' in user_name) as VOWEL_COUNT
from public.users;
Not as fancy, but does it's job.
- Lars
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.