Você está na página 1de 6

# 1) Query to do the following task Table1 data as follows Name Sribharath Reddy Peketi Raju Kumar Godugu Venkat

## Rao Vennapu Ramesh kumar sanagalakuruba

Table 2 must come as follows First_name Sribharath Raju Venkat Ramesh Middle_name Reddy Kumar Rao Kumar Last name Peketi Godugu Vennapu SanagalaKuruba

insert into nani3(firstn,middlem,lastm) (select substr(name,1,instr(name,' ',1)), substr(name,instr(name,' ',1),(instr(name,' ',-1)instr(name,' ',1))), substr(name,instr(name,' ',-1)) from nani1); 2) Query to do the following task
Character Value=22,11,123,458 Convert the above character value into number as 2211123458

SELECT TO_NUMBER(22,11,123,458,99,99,999,999) FROM DUAL; 3) Query to convert the number values into words like 10,123=Ten Thousand One Hundred Twenty Three
select (TO_CHAR(TO_DATE(:num,'J'),'JSP')) from dual

OR HERE IS THE FUNCTION PL/SQL PROGRAM create or replace function spell_number( p_number in number )

return varchar2 as type myArray is table of varchar2(255); l_str myArray := myArray( '', ' thousand ', ' million ', ' billion ', ' trillion ', ' quadrillion ', ' quintillion ', ' sextillion ', ' septillion ', ' octillion ', ' nonillion ', ' decillion ', ' undecillion ', ' duodecillion ' ); l_num varchar2(50) default trunc( p_number ); l_return varchar2(4000); begin for i in 1 .. l_str.count loop exit when l_num is null; if ( substr(l_num, length(l_num)-2, 3) <> 0 ) then l_return := to_char( to_date( substr(l_num, length(l_num)-2, 3), 'J' ), 'Jsp' ) || l_str(i) || l_return; end if; l_num := substr( l_num, 1, length(l_num)-3 ); end loop; return l_return; end; --AFTER RUNNING FUNCTION SUCCESSFULLY

## select SPELL_NUMBER( 1112345678901234567890123456789012345678 ) from dual;

O/P:
One duodecillion One Hundred Twelve undecillion Three Hundred Forty-Five decillion Six Hundred Seventy-Eight nonillion Nine Hundred One octillion Two Hundred Thirty-Four septillion Five Hundred Sixty-Seven sextillion Eight Hundred Ninety quintillion One Hundred Twenty-Three quadrillion Four Hundred Fifty-Six trillion Seven Hundred Eighty-Nine billion Twelve million Three Hundred Forty-Five thousand Six Hundred Seventy-Eight

## 4) Query to do the following Task

Department wise all the names should come like.. Deptno 10 20 30 40 Deptno 10 20 30 40 Names Nani,Ganesh,Bharath Raju,Rani,Vani Xyz,abc,pqr Joe,Jay

Eg.. answer select deptno, wm_concat(ename) Names from emp group by deptno; 5) I have a table where I have to do a update
create table demo(col1 varchar2(10)); insert insert insert insert insert insert into into into into into into demo demo demo demo demo demo values('XX0024'); values('XX4345'); values('XX2300'); values('XX0124'); values('XX2024'); values('XX0004');

the Question is, when I update the result should be col1 ----24 4345 2300 124 24 4 I have to replace XX and preceding 0 if any Answer is

## 6) Query to do the following task

Ename SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER Bharath Should appear like the following

Ename