Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Share
More
Next Blog
Home
AP
INV
OM
AR
GL
PO
HR
PA
FAQS
OAF
PL SQL
CONV
TOOLS
SCRIPTS
SEARCH
9 4
LABELS 11i (32) ADI (8) AIM (3) ALERTS AME (7) AOL (79) AP (127) API (14) APPLICATIONS AR (91) ASSETS BANKS BOM (3) BPEL (6) BURSTING C/C++ (5) CASH (13) CHECKS CMD (2) CONVERSIONS CRM (6) CUSTOM.PLL DATA LOADER DBA (77) DISCOVERER DOCUMENTS EDI (1) eText (9) FA (9) FAQS (274) FLEX FIELDS FNDLOAD FORM PERS FORMS FORMS PERS FUNCTIONAL FUSION GL (96) HRMS (55) iEXPENSE INDEXES INFORMATICA INTERFACES INV (46) iSTORE
or select * from emp where empno not in (select mgr from emp where mgr is not null); or select * from emp e where empno not in (select mgr from emp where e.empno=mgr);
24. select job from emp where job not in ('CLERK','ANALYST','SALESMAN'); 25. set pause on; 26. select count(*) from emp; 27. select sum(sal), sum(nvl(comm,0)) from emp; 28. select max(sal) from emp; 29. select min(sal) from emp; 30. select avg(sal) from emp; 31. select max(sal) from emp where job='CLERK'; 32. select max(sal) from emp where deptno=20;
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
1/7
4/16/2014
33. select min(sal) from emp where job='SALESMAN'; 34. select avg(sal) from emp where job='MANAGER'; 35. select sum(sal)+sum(nvl(comm,0)) from emp where deptno=40; 36. select ename from emp order by sal; 37. select ename from emp order by sal desc; 38. select ename from emp order by ename; 39. select * from emp order by ename,deptno,sal; 40. Ans:select ename,sal,sal*12 "Annual Salary" from emp order by "Annual Salary" desc; 41. select ename,sal SA,sal*0.15 HRA,sal*0.10 DA,sal*5/100 PF, sal+(sal*0.15)+(sal*0.10)-(sal*.05) TOTALSALARY from emp
PROFILE OPTION
;
62. select ename,deptno from tvsemp where sal>all(select max(sal) from tvsemp where deptno!=10 group by deptno) and deptno=10
;
63. select upper(ename) from tvsemp; 64. select Lower(ename) from tvsemp; 65. select InitCap(ename)from tvsemp; 66. select lentgh('RAMA') from dual; 67. select length(ename) from tvsemp; 68. select ename||' '||empno from tvsemp; 69. select substr('Oracle',3,2) from dual; 70. select lstr('Computer Maintenance Corporation','a' ) from dual; 71. select translate('Alliens','A','B') from Dual; 72. select ename ,replace(job,'MANAGER','BOSS') from tvsemp; 73. select empno,ename,deptno,Decode(deptno,10,'ACCOUNTING' ,20,'RESEARCH',30,'SALES','OPERATIONS')DName from
SQLDEVELOPER
tvsemp;
74. select sysdate-to_date('30-jul-1977') from dual; 75. select months_between(sysdate,to_date('30-jul-1977')) from dual; 76. select To_char(sysdate,'ddth Month Day year') from dual; 77. 78. select empno,ename,to_char(Hiredate,' Day ddth Month year') from tvsemp;
ORACLE BLOGS
BLOG ARCHIVE
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
2/7
4/16/2014
79. select next_day(sysdate,'Saturday') from dual; 80. select To_Char(sysdate,'HH:MI:SS') from dual; 81. select Add_months(sysdate,-3) from dual 82. select job from tvsemp where job in (select job from tvsemp where deptno=20) and deptno=10; 83. select Distinct job from tvsemp where deptno in(10,20); 84. select job from tvsemp where deptno=10; 85. select empno,ename,job from tvsemp where empno not in (select mgr from tvsemp where mgr is not null ); 86. select e.ename,d.dname, grade from emp e,dept d ,salgrade where e.deptno=d.deptno and dname='SALES' and grade=3; 87. select ename from tvsemp where job!='MANAGER'; 88. select ename from tvsemp where length(ename)>=4 ;
89. select e.ename, d.loc from tvsemp e ,tvsdept d where d.loc like('%K') and ename like('S%') 90. select e.ename Superior, e1.ename Subordinate from tvsemp e,e1 where e.empno=e1.mgr and e.ename='JONES'; 91. select ename, sal, (sal+(sal*0.20)) from tvsemp where (sal+(sal*0.20))>3000; 92. select e.ename, d.dname from tvsemp e, tvsdept d where e.deptno=d.deptno 93. select e.ename, d.dname from emp e, dept d where e.deptno=d.deptno and d.dname='SALES'; 94. Select e.ename, d.dname, e.sal, e.comm from tvsemp e, dept d where e.deptno=d.deptno and sal between 2000 and 5000; 95. Select e.ename, e.sal, e1.ename,e1.sal from tvsemp e,e1 where e.mgr=e1.empno and e.sal>e1.sal; 96. select e.ename,e.deptno,e1.ename,e1.deptno from tvsemp e,e1 where e.mgr=e1.empno and e.deptno=e1.deptno; 97. select ename from tvsemp where mgr is null; 98. select ename,grade,deptno,sal from tvsemp ,salgrade where ( grade,sal) in
(select grade, sal from salgrade, tvsemp where sal between losal and hisal) and grade!=4 and deptno in (10,30) and hiredate<'31-Dec-82';
99. update tvsemp set sal= (sal+(sal*0.10)) where comm is null; 100. select e.ename, e.hiredate, d.loc from tvsemp e,tvsdept d where e.deptno=d.deptno and hiredate<'31-Dec-82' and d.loc in
('NEWYORK','CHICAGO');
101. select e.ename,e.job,d.dname,d.loc from tvsemp e,tvsdept d where e.deptno=d.deptno and e.empno in (select mgr from tvsemp
OR select grade, sal, hisal from tvsemp, salgrade where ename='FORD' and sal between losal and hisal; OR select ename, sal, hisal, grade from tvsemp, salgrade where ename= 'FORD' and (grade,sal) in (select grade, hisal from salgrade,tvsemp where sal between losal and hisal);
104. select e.ename sub,e1.ename sup, e.job, d.dname ,grade from tvsemp e,e1,salgrade,tvsdept d where e.mgr=e1.empno and e.sal
between losal and hisal and e.deptno=d.deptno group by d.deptno,e.ename,e1.ename,e.job,d.dname,grade; OR select e.ename sub,e1.ename sup,e.job,d.dname ,grade from tvsemp e,e1,salgrade,tvsdept d where e.mgr=e1.empno and e.sal between losal and hisal and e.deptno=d.deptno;
105. select e.ename, e.job, e.sal, d.dname ,grade from tvsemp e,salgrade, tvsdept d where (e.deptno=d.deptno and e.sal between losal
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
3/7
4/16/2014
110. select count(*) from tvsemp group by deptno having count(*)>3 111. select d.dname from tvsdept d, tvsemp e where e.deptno=d.deptno group by d.dname having count(*)>3; 112. select distinct e1.ename,e1.sal from tvsemp e,e1,dept d where e.deptno=d.deptno and e.mgr=e1.empno and e1.sal> (select
>any (select e2.sal from tvsemp e2, e,tvsdept d1 where e.mgr=e2.empno and d1.deptno=e.deptno);
116. Select ename, (select sum(sal) from emp) total_sal from emp; 117. select rn, lev,empno,sal,job from (Select rownum rn, lev, empno,sal, job, mgr from ( Select level lev , empno, ename, sal, job,
mgr from emp connect by prior empno = mgr start with mgr is null order by level desc) ) where rn <=5;
118. Select e.ename,e.sal,e1.ename,e1.sal from tvsemp e,e1,tvsdept d where e.deptno=d.deptno and e.mgr=e1.empno and
e.sal>e1.sal;
119. select e2.ename from emp e1,emp e2,emp e3 where e1.mgr=e2.empno and e2.mgr=e3.empno and e3.job!='PRESIDENT'; 120. delete from tvsemp where empno is null; 121. delete from tvsemp e where e.deptno not in (select deptno from tvsdept); 122. select empno,sal from tvsemp where sal<(select min(LOSAL) from salgrade ) ;
to_char(hiredate,'yyyy')=30;
125. select ename ,sal from tvsemp where mod(sal,2)!=0; 126. select ename,sal from tvsemp where length(sal)=3; 127. Select empno, ename from tvsemp where trim(to_char(hiredate,'Mon')) =trim('DEC'); 128. select ename from tvsemp where ename like('%A%'); 129. select ename,sal from tvsemp where deptno in (select distinct sal from tvsemp); 130. select empno, hiredate, sal from tvsemp where trim(substr(hiredate,1,2)) = trim(substr(sal,-2,2));
e.deptno)
141. select a.ename,b.ename from tvsemp a,tvsemp b where a.hiredate=b.hiredate and a.empno!=b.empno 142. select ename,sal,grade ,substr(sal,grade,1) from tvsemp,salgrade where
grade!=substr(sal,1,1) and grade = substr(sal,grade,1) and sal between losal and hisal
143. Select count(empno) from tvsemp where empno in (select a.empno from tvsemp a
4/16/2014
144. select a.ename,b.ename from tvsemp a,tvsemp b where a.hiredate=b.hiredate and a.empno!=b.empno; 145. select e2.ename,count(*) from tvsemp e1,e2 where e1.mgr=e2.empno group by e2.ename Having count(*)=(select max(count(*))
( case when sal < 1500 then 'Below_Target' when sal=1500 then 'On_Target' when sal > 1500 then 'Above_Target' else 'kkkkk' End ) from tvsemp ;
150. ; 151. 152. select ename,hiredate, LAST_DAY ( next_day(hiredate,'Friday')),
case when to_char(hiredate,'dd') <=('15') then LAST_DAY ( next_day(hiredate,'Friday')) when to_char(hiredate,'dd')>('15') then LAST_DAY( next_day(add_months(hiredate,1),'Friday')) end case from tvsemp ;
153. select a.empno,a.ename ,a.sal,b.sal,b.empno,b.ename from tvsemp a, tvsemp b where a.mgr=b.empno and a.sal>b.sal 154. select a.empno,a.ename ,b.ename from tvsemp a, tvsemp b where a.mgr=b.empno and b.ename='BLAKE' 155. select * from emp where empno in (select mgr from emp); 156. select * from emp where mgr=(select empno from emp where ename='JONES') union select * from emp where empno = (select
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
5/7
4/16/2014
178. select * from emp where sal>all(select sal from emp where deptno=30); 179. select deptno from emp group by deptno having count(*)>3; 180. select * from emp where rownum < 11 minus select * from emp where rownum< 10; 181. select ename, upper(substr(ename,0,length(ename)/2)) || lower(substr(ename,length(ename)/2+1, length(ename))) UP_lo from
emp
182. create table emp1 as select * from emp; 183. delete from emp where empno = ( select empno from emp where rownum < 11 minus select empno from emp where rownum<
10);
184. create table copyEMP as select * from emp; 185. select distinct(ename) from emp e where ename in (select ename from emp where e.empno<>empno); 186. select ename from emp order by ename desc; 187. select empno,ename from emp e,salgrade s where e.sal between s.losal and s.hisal and to_char(hiredate, 'mm')=grade; 188. select * from emp where to_char(hiredate,'dd') =deptno; 189. select substr(ename,1,1)||''||ename from emp; 190. select ename,sal,sal*15/100 pf from emp; 191. . 192. create table emp (empno number(5)); 193. alter table emp add ename varchar2(20) not null; 194. alter table emp add constraint emp_empno primary key (empno); 195. alter table emp modify ename varchar2(30); 196. alter table emp add sal number(7,2); 197. alter table emp add constraint emp_sal_check check(sal<10000); 198. alter table emp disable constraint emp_sal_check; 199. alter table emp enable constraint emp_sal_check; 200. alter table emp add mgr number(5); 201. Alter table emp add constraint emp_mgr foreign key (empno; 202. alter table emp add deptno number(3); 203. alter table emp1 add constraint emp1_deptno foreign key (deptno) references dept(deptno); 204. create table newemp as select * from emp; 205. create table newemp as select empno,ename,dname from emp e,dept d where e.deptno=d.deptno; 206. delete from emp where floor(sysdate-hiredate)>2*365; 207. select emp set comm=300 where comm is null; 208. update emp set comm=comm*10/100 where comm is not null; 209. select ename,dname from emp e,dept d where e.deptno=d.deptno; 210. select empno,ename,loc from emp e,dept d where e.detpno=d.deptno; 211. select ename,dname from emp e,dept d where e.deptno(+)=d.deptno; 212. select e.ename,m.ename from emp e,emp m where e.mgr=m.empno; 213. select deptno,sum(sal) from emp group by deptno; 214. select deptno,count(*) from emp group by deptno; 215. select table_name from user_constraints where R_constraint_name IN (select constraint_name FROM USER_CONSTRAINTS
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
6/7
4/16/2014
Comment as:
Google Account
Publish
Preview
Newer Post
Subscribe to: Post Comments (Atom)
Home
Older Post
Email : OracleApps88@Yahoo.com
Email : oracleapps88@yahoo.com. Picture Window template. Template images by konradlew. Powered by Blogger.
Get Flower Effect
http://oracleapps88.blogspot.in/2011/10/oracle9i-sql-queries-answers.html
7/7