SQL to count number of occurrences of a vowels
create table emp(empno number,ename varchar2(100));
WITH ds AS (
SELECT empno,
upper(ename) ename,
length(ename) l
FROM emp)
SELECT *
FROM
(
SELECT empno,ename,c,COUNT(*) cnt
FROM
(
SELECT empno, ename,substr(ename, r, 1) c
FROM
ds,
LATERAL ( SELECT ROWNUM r
FROM dual
CONNECT BY level <= l)
)
WHERE
c IN ('A','E','I','O','U')
GROUP BY empno,ename,c
) PIVOT ( MAX ( cnt ) FOR c IN ( 'A','E','I','O','U' ));
Your email id sir
ReplyDeleteEmail id sir
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWe are one of the authorized people for bus branding in Chennai metropolitan and across Tamilnadu.
ReplyDeleteBus Advertising Agency in Chennai
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletegreat post and the best ielts training institute in ernakulam
ReplyDeleteSELECT
ReplyDeletestring_column,
LENGTH(string_column) - LENGTH(REPLACE(LOWER(string_column), 'a', '')) AS count_a,
LENGTH(string_column) - LENGTH(REPLACE(LOWER(string_column), 'e', '')) AS count_e,
LENGTH(string_column) - LENGTH(REPLACE(LOWER(string_column), 'i', '')) AS count_i,
LENGTH(string_column) - LENGTH(REPLACE(LOWER(string_column), 'o', '')) AS count_o,
LENGTH(string_column) - LENGTH(REPLACE(LOWER(string_column), 'u', '')) AS count_u
FROM
table_data;
select ename,length(ename) - length(translate(upper(ename),'AEIOU','')) NO_of_vowels from emp e ;
ReplyDelete