Escolar Documentos
Profissional Documentos
Cultura Documentos
Table 2 must come as follows First_name Sribharath Raju Venkat Ramesh Middle_name Reddy Kumar Rao Kumar Last name Peketi Godugu Vennapu SanagalaKuruba
Answer
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
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
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
Ename SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER Bharath Should appear like the following
Ename
SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER,Bharath
Answer:
SELECT WM_CONCAT(ENAME) ENAME FROM EMP; {guess WM_CONCAT FUNCTION WORKS FROM 10g onwards} 7) Query to do the following Task
I have a table as below: create table test ( id number(5), value varchar2(10)); insert into test values(1,'val1'); insert into test values(2,''); insert into test values(3,'val3'); insert into test values(4,''); insert into test values(5,''); insert into test values(6,'val6'); insert into test values(7,''); commit; SQL> select *from test; ID VALUE ---------- ---------1 val1 2 3 val3 4 5 6 val6 7 I need to write an update statement which will update the table as below: SQL> select *from test; VALUE ---------val1 val1 val3 val3 val3 val6 val6
ID ---------1 2 3 4 5 6 7
the null value for an ID should inherit the previous non null value. Answer:
merge into test using ( select id, new_val from (select id, value, last_value(value ignore nulls) over (order by id) new_val from test) where value is null) t_new on (test.id = t_new.id)