Saturday, April 10, 2010

Oracle SQL query to select only all words in capitals

select * from
(select REGEXP_SUBSTR (ename, '[^ ]+', 1, level) word
from ename
connect by level <= length(regexp_replace(ename,'[^ ]*'))+1 ) where regexp_instr(word,'[A-Z]') > 0;

Oracle Sql query to display half employee name in upper case & other half in lower case

SELECT ename,
LOWER (SUBSTR (ename, 1, ROUND (LENGTH (ename) / 2)))
|| UPPER (SUBSTR (ename, ROUND (LENGTH (ename) / 2) + 1, LENGTH (ename)))
a
FROM emp;