Vous êtes sur la page 1sur 10

1)CREATE TABLESPACE USER_DATA1 DATAFILE 'DATA.

DAT' SIZE 10M ONLINE CREATE USER PRASAD IDENTIFIED BY PRASAD DEFAULT TABLESPACE USER_DATA1 GRANT CONNECT,RESOURCE,DBA TO PRASAD; CREATE TABLE DEPT_NN(DEPTNO NUMBER(2) CONSTRAINT PK_DEPTNO_NN PRIMARY KEY, DNAME VARCHAR2(14),LOC VARCHAR2(13)); 2)CREATE TABLE EMP_NN(EMPNO NUMBER(4) CONSTRAINT PK_EMPNO_NN PRIMARY KEY, ENAME VARCHAR2(10),JOB VARCHAR2(9),MGR NUMBER(4),HIREDATE DATE,SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(2)); 3)ALTER TABLE EMP_NN ADD CONSTRAINT FK_DEPTNO_NN FOREIGN KEY(DEPTNO) REFERENCES DEPT_NN(DEPTNO) 4)INSERT ALL INTO DEPT_NN(DEPTNO,DNAME,LOC) SELECT DEPTNO,DNAME,LOC FROM SCOTT.D EPT; INSERT ALL INTO EMP_NN(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO FRO MSCOTT.EMP; 5) SELECT JOB,SAL FROM EMP_NN WHERE MGR IN (7698,7566) AND SAL>1500; 6)SELECT AVG(MAX(SAL)) FROM EMP_NN GROUP BY DEPTNO; 7) UPDATE EMP_NN SET SAL=(SELECT MIN(SAL) FROM EMP_NN WHERE JOB='MANAGER') WHERE DEPTNO=30 AND JOB='SALESMAN'; 8) SELECT ENAME, E.DEPTNO,DNAME FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND JOB='SALESMAN'; 9)SELF JOIN: SELECT M.ENAME,E.ENAME FROM EMP_NN E,EMP_NN M WHERE M.MGR=E.EMPNO; (OR) SELECT E.ENAME ,M.MGR FROM EMP_NN E,EMP_NN M WHERE E.ENAME=M.ENAME; 10)EQUI JOIN: SELECT ENAME, E.DEPTNO,DNAME,LOC FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND LOC='CHICAGO'; 11)SELECT MAX(SAL),MIN(SAL) FROM EMP_NN GROUP BY DEPTNO; ________________________________________________________________________________ ________________ 1)SELECT * FROM EMP_NN; 2)SELECT DISTINCT JOB FROM EMP_NN; 3)SELECT * FROM EMP_NN ORDER BY SAL; 4)SELECT * FROM EMP_NN ORDER BY DEPTNO,JOB DESC; 5)SELECT DISTINCT JOB FROM EMP_NN ORDER BY JOB DESC 6) SELECT * FROM EMP_NN WHERE EMPNO IN (SELECT DISTINCT MGR FROM EMP_NN); 7)SELECT * FROM EMP_NN WHERE HIREDATE<'01-JAN-1981'; (OR) SELECT * FROM EMP_NN WHERE TO_CHAR(HIREDATE,'YY')<81; 8) SELECT EMPNO,ENAME,SAL,SAL/30 "DAILY SAL" FROM EMP_NN ORDER BY SAL;

9) SELECT MONTHS_BETWEEN(SYSDATE,HIREDATE)/12 FROM EMP_NN; (OR) SELECT TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(HIREDATE,'YYYY') FROM EMP_NN; 10)SELECT EMPNO,ENAME,SAL,MGR,MONTHS_BETWEEN(SYSDATE,HIREDATE)/12 EXP FROM EMP_ NN WHERE MGR=7839 1) SELECT * FROM EMP_NN WHERE SAL<COMM 12) SELECT * FROM EMP_NN WHERE HIREDATE>'01-JUL-1981' ORDER BY JOB 13) SELECT ENAME,SAL,SAL/30 "DAILY SAL", MONTHS_BETWEEN(SYSDATE,HIREDATE)/12 EXP FROM EMP_NN WHERE SAL/30>100 14) SELECT * FROM EMP_NN WHERE JOB IN ('CLERK','ANALYST') ORDER BY JOB 15) SELECT * FROM EMP_NN WHERE HIREDATE IN ('01-MAY-81',03-DEC-81','17-DEC-81',1 9-JAN-80') ORDER BY HIREDATE; 16) SELECT * FROM EMP_NN WHERE DEPTNO IN (10,20); 17)SELECT * FROM EMP_NN WHERE HIREDATE LIKE '%81' 18)SELECT * FROM EMP_NN WHERE HIREDATE LIKE '%80' AND HIREDATE LIKE '%DEC%' 19) SELECT EMPNO,ENAME,SAL,SAL*12 ANNUAL FROM EMP_NN WHERE SAL*12 BETWEEN 22000 AND 45000 20) SELECT * FROM EMP_NN WHERE LENGTH(ENAME)=5 21) SELECT * FROM EMP_NN WHERE LENGTH(ENAME)=5 AND ENAME LIKE 'S%' 22) SELECT * FROM EMP_NN WHERE LENGTH(ENAME)=4 AND ENAME LIKE '__R%' 23) SELECT * FROM EMP_NN WHERE ENAME LIKE 'S%' AND ENAME LIKE '%H' 24) SELECT * FROM EMP_NN WHERE HIREDATE LIKE ('%JAN%') 25) SELECT * FROM EMP_NN WHERE TO_CHAR(HIREDATE,'MON' ) LIKE ('_A%') 26) SELECT * FROM EMP_NN WHERE LENGTH(SAL)=4 AND SAL LIKE('%0') 27) SELECT * FROM EMP_NN WHERE ENAME LIKE('%LL%') 28) SELECT * FROM EMP_NN WHERE HIREDATE LIKE('%80') 29) SELECT * FROM EMP_NN WHERE DEPTNO NOT IN 20 30) SELECT * FROM EMP_NN WHERE JOB NOT IN ('PRESIDENT','MANAGER' ) ORDER BY SAL 31) SELECT * FROM EMP_NN WHERE TO_CHAR(HIREDATE,'YY') NOT IN '81' 32) SELECT * FROM EMP_NN WHERE EMPNO LIKE '78%'; 33) SELECT * FROM EMP_NN WHERE JOB='MANAGER' 34) SELECT * FROM EMP_NN WHERE HIREDATE NOT LIKE ('%NOV%')

35) SELECT * FROM EMP_NN WHERE DEPTNO =20 AND JOB='CLERK' 36) SELECT * FROM EMP_NN WHERE DEPTNO IN (10,30) AND HIREDATE LIKE '%81' 37)SELECT * FROM EMP_NN WHERE ENAME='SMITH' 38) SELECT ENAME,LOC FROM EMP_NN,DEPT_NN WHERE EMP_NN.DEPTNO=DEPT_NN.DEPTNO AND ENAME='SMITH'; 39) SELECT ENAME,SAL,HIREDATE,EMP_NN.DEPTNO,DNAME,LOC FROM EMP_NN,DEPT_NN WHERE EMP_NN.DEPTNO=DEPT_NN.DEPTNO AND DNAME IN('ACCOUNTING','RESEARCH') ORDER BY DEPT NO 40)SELECT EMPNO, ENAME, SAL,JOB,HIREDATE,DNAME,LOC, MONTHS_BETWEEN(SYSDATE,HIRED ATE)/12 EXP FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND JOB IN ('MANAGER ','ANALYST') AND LOC IN ('NEW YORK','DALLAS') AND ((MONTHS_BETWEEN(SYSDATE,HIRED ATE)/12)>7) ORDER BY LOC 41)SELECT EMPNO, ENAME, SAL,JOB,HIREDATE,DNAME,LOC, SAL*12 ANN_SAL FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND (LOC = 'CHICAGO' OR DNAME ='ACCOUNTING' ) AND SAL*12 >2800 AND SAL NOT IN (2000,3000) AND JOB NOT IN 'MANAGER' AND (EMPNO NOT LIKE(' __7%') OR EMPNO NOT LIKE('__8%')) ORDER BY E.DEPTNO,JOB DESC; 42) SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO, GRADE FROM SALGRADE S,EMP_NN E WHERE SAL>LOSAL AND SAL<HISAL; 43) SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO, GRADE FROM SALGRADE S,EMP_NN E WHERE SAL>LOSAL AND SAL<HISAL AND GRADE IN (2,3) 44) SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO, GRADE FROM SALGRADE S,EMP_NN E WHERE SAL>LOSAL AND SAL<HISAL AND GRADE IN (4,5) AND JOB IN ('MANAGER','ANALY ST') 45)SELECT EMPNO,ENAME,HIREDATE,SAL,E.DEPTNO, GRADE,DNAME,SAL*12 "ANNUAL SAL",MON THS_BETWEEN(SYSDATE,HIREDATE)/12 "EXP" FROM DEPT_NN D,SALGRADE S,EMP_NN E WHERE SAL>LOSAL AND SAL<HISAL AND E.DEPTNO=D.DEPTNO AND E.DEPTNO IN (10,20) 46) SELECT EMPNO,ENAME,JOB,HIREDATE,SAL,E.DEPTNO, GRADE,DNAME,LOC FROM DEPT_NN D ,SALGRADE S,EMP_NN E WHERE SAL>LOSAL AND SAL<HISAL AND E.DEPTNO=D.DEPTNO AND GRA DE IN (2,3,4) AND DNAME NOT LIKE ('OP%') AND DNAME NOT LIKE ('%S') AND JOB LIKE( '%A%') AND TO_CHAR ( HIREDATE,'YY') LIKE ('81%') AND TO_CHAR(HIREDATE,'MON') NOT IN ('MAR','SEP') AND SAL NOT LIKE ('%00') ORDER BY GRADE 47) SELECT D.DEPTNO,DNAME,LOC,EMPNO,ENAME FROM DEPT_NN D,EMP_NN E WHERE E.DEPTNO =D.DEPTNO 48) SELECT * FROM EMP_NN WHERE SAL>(SELECT SAL FROM EMP_NN WHERE ENAME='BLAKE') 49) SELECT * FROM EMP_NN E WHERE JOB=(SELECT JOB FROM EMP_NN WHERE ENAME='ALLEN' ) 50) SELECT * FROM EMP_NN E WHERE HIREDATE<(SELECT HIREDATE FROM EMP_NN WHERE ENA ME='KING'); 51) SELECT E.ENAME EMPLOYEE, E.HIREDATE "EMP HIREDATE",M.ENAME MANAGER ,M.HIREDA TE "MANAGER HIREDATE" FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND E.HIREDATE< M.HIREDATE; 52) SELECT * FROM EMP_NN WHERE DEPTNO=20 AND JOB IN(SELECT JOB FROM EMP_NN WHERE

DEPTNO=10); 53)SELECT * FROM EMP_NN WHERE SAL IN( SELECT SAL FROM EMP_NN WHERE ENAME IN ('FO RD','SMITH')) ORDER BY SAL DESC 54)SELECT * FROM EMP_NN WHERE JOB IN (SELECT JOB FROM EMP_NN WHERE ENAME ='MILLE R') AND SAL<(SELECT SAL FROM EMP_NN WHERE ENAME='ALLEN') 55)SELECT * FROM EMP_NN WHERE SAL > SUM((SELECT SAL+NVL(COMM,0) FROM EMP_NN WHER E JOB='CLERK') 56) SELECT EMPNO,ENAME,E.DEPTNO,DNAME,LOC FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO =D.DEPTNO AND HIREDATE < (SELECT HIREDATE FROM EMP_NN WHERE ENAME='BLAKE') AND L OC IN ('CHICAGO','BOSTON') 57)SELECT EMPNO,ENAME,HIREDATE,E.DEPTNO, DNAME, LOC, GRADE FROM SALGRADE S,EMP_N N E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND (E.SAL>S.LOSAL AND E.SAL<HISAL) AND GR ADE IN(3,4) AND DNAME IN('ACCOUNTING','RESEARCH') AND SAL>(SELECT SAL FROM EMP_N N WHERE ENAME='SMITH') ORDER BY HIREDATE 58)SELECT * FROM EMP_NN WHERE JOB IN ( SELECT JOB FROM EMP_NN WHERE ENAME IN ('S MITH','ALLEN')) 59) 60)SELECT JOB FROM EMP_NN WHERE DEPTNO=20 AND JOB NOT IN ( SELECT JOB FROM EMP_N N WHERE DEPTNO=30) 61) 62) SELECT MAX(SAL) FROM EMP_NN; 63)SELECT * FROM EMP_NN WHERE SAL=(SELECT MAX(SAL) FROM EMP_NN) 64)SELECT * FROM EMP_NN WHERE SAL=(SELECT MAX(SAL) FROM EMP_NN WHERE JOB='SALESM AN' ) AND JOB='SALESMAN'; 65)SELECT * FROM EMP_NN WHERE HIREDATE=(SELECT MAX(HIREDATE) FROM EMP_NN E,SALGR ADE S,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND E.SAL>S.LOSAL AND E.SAL<S.HISAL AND GRADE=3 AND LOC='CHICAGO'); 66)SELECT E.* FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND E.HIREDATE< ( SELECT MAX(E.HIREDATE) FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND M.ENAME='KING') AND M.ENAME='KING'; 67)SELECT E.ENAME ,E.SAL,LOC,GRADE,JOB FROM EMP_NN E,DEPT_NN D,SALGRADE S WHERE E.DEPTNO=D.DEPTNO AND E.SAL BETWEEN S.LOSAL AND S.HISAL AND GRADE IN(3,4,5) AND LOC='NEW YORK' AND JOB NOT IN 'PRESIDENT' AND SAL> (SELECT SAL FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND

SAL O AND AND AND AND

=(SELECT MAX(E.SAL) FROM EMP_NN E, EMP_NN M,DEPT_NN D WHERE E.DEPTNO=D.DEPTN D.LOC='CHICAGO' E.JOB IN ('MANAGER','ANALYST') E.MGR=M.EMPNO M.ENAME NOT IN 'KING'))

73)SELECT SUM(SAL) FROM EMP_NN E,SALGRADE S WHERE E.SAL BETWEEN S.LOSAL AND S.HISAL AND GRADE=3; 74)SELECT AVG(SAL) FROM EMP_NN WHERE JOB='CLERK'; 75) SELECT * FROM EMP_NN WHERE DEPTNO=20 AND SAL>(SELECT AVG(SAL) FROM EMP_NN WH ERE DEPTNO=30); 76)SELECT JOB,DEPTNO,COUNT(*) FROM EMP_NN GROUP BY JOB,DEPTNO; 77)SELECT M.ENAME,M.EMPNO,COUNT(*) FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO GR OUP BY M.ENAME,M.EMPNO 78) SELECT DNAME,COUNT(*) FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO GROUP BY DNAME HAVING COUNT(*) >2 79)SELECT GRADE,COUNT(GRADE), MAX(SAL) FROM EMP_NN E ,SALGRADE S WHERE E.SAL BET WEEN S.LOSAL AND S.HISAL GROUP BY GRADE 80)SELECT GRADE,JOB,COUNT(*) FROM EMP_NN E ,SALGRADE S WHERE E.SAL BETWEEN S.LOSAL AND S.HISAL GROUP BY GRADE,JOB HAVING JOB='CLERK' AND COUNT(*)>2 81) 82) SELECT E.ENAME,M.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND M.ENAM E='JONES'; 83)SELECT EMP_NN.* ,SAL+(SAL*20/100) INC FROM EMP_NN WHERE (SAL+(SAL*20/100)>300 0) 84)SELECT ENAME,DNAME FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO; 85)SELECT ENAME,DNAME FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO AND DNAME NOT IN 'SALES'; 86)SELECT ENAME,DNAME,SAL,COMM FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO A ND SAL BETWEEN 2000 AND 5000 AND LOC='CHICAGO' 87)SELECT E.ENAME,E.SAL,M.ENAME,M.SAL FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND M.SAL<E.SAL; 88)SELECT ENAME,DEPTNO,HIREDATE,GRADE FROM EMP_NN E,SALGRADE S WHERE E.SAL BETW EEN S.LOSAL AND S.HISAL AND DEPTNO IN(10,30) AND GRADE NOT IN (4) AND HIREDATE<'31-DEC-1982'; 89)SELECT DISTINCT M.ENAME,M.JOB,DNAME,LOC FROM EMP_NN E,EMP_NN M,DEPT_NN D WHER E (E.MGR=M.EMPNO OR E.MGR=NULL) AND E.DEPTNO=D.DEPTNO AND M.JOB='MANAGER'

90)SELECT M.ENAME MANAGERS,E.ENAME EMPLOYEES FROM EMP_NN E , EMP_NN M WHERE E.M GR=M.EMPNO AND E.ENAME IN ( SELECT E.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND M.ENAME='JONES' OR E.ENAME='JONES' ) 91)SELECT ENAME,SAL,GRADE FROM EMP_NN E,SALGRADE S WHERE ENAME='FORD' AND E.SAL BETWEEN S.LOSAL AND S.HISAL AND E.SAL=S.HISAL 92)SELECT E.ENAME,E.JOB,D.DNAME,M.ENAME MANAGER,E.SAL ,E.DEPTNO FROM EMP_NN E,DE PT_NN D,EMP_NN M WHERE E.DEPTNO=D.DEPTNO AND E.MGR=M.EMPNO ORDER BY DEPTNO; 93)SELECT E.ENAME,E.JOB,D.DNAME,E.SAL ,E.DEPTNO,S.GRADE FROM EMP_NN E,DEPT_NN D, SALGRADE S WHERE E.DEPTNO=D.DEPTNO AND E.SAL BETWEEN S.LOSAL AND S.HISAL AND JOB NOT IN 'CLERK' ORDER BY E.SAL; 94)SELECT E.ENAME EMP,E.JOB,M.ENAME MGR FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMP NO(+) MINUS SELECT E.ENAME EMP,E.JOB,M.ENAME MGR FROM EMP_NN E,EMP_NN M WHERE E. MGR=M.EMPNO 95) SELECT ENAME,DEPTNO,SAL FROM EMP_NN WHERE SAL IN (SELECT MAX(SAL) FROM EMP_N N GROUP BY DEPTNO); 96) SELECT * FROM EMP_NN WHERE SAL= (SELECT AVG (SAL)FROM EMP_NN WHERE SAL IN ((SELECT MIN(SAL) FROM EMP_NN),(SELECT MAX(SAL) FROM EMP_NN))); 97)SELECT DEPTNO,COUNT(*) FROM EMP_NN GROUP BY DEPTNO HAVING COUNT(*) >3; 98)SELECT DNAME FROM DEPT_NN WHERE DEPTNO IN ( SELECT DEPTNO FROM EMP_NN GROUP BY DEPTNO HAVING COUNT(*) >3) 99)SELECT M.ENAME,AVG(E.SAL),M.SAL FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO GROUP BY M.ENAME,M.SAL HAVING M.SAL > AVG(E.SAL) 100) 101)SELECT M.ENAME,E.ENAME,E.SAL,M.SAL FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND E.SAL > M.SAL AND E.SAL>= (SELECT MAX(M.SAL) FROM EMP_NN M) 102)SELECT ENAME,SAL,SAL*12,DEPTNO FROM EMP_NN GROUP BY DEPTNO,SAL,ENAME 103)SELECT ENAME,SAL FROM (SELECT ENAME,SAL FROM EMP_NN ORDER BY SAL) WHERE ROWN UM<=5 104)SELECT COUNT(*) FROM EMP_NN E ,EMP_NN M WHERE E.MGR=M.EMPNO AND E.SAL>M.SAL 105) SELECT E.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND E.ENAME IN (SELECT DISTINCT M.ENAME FROM EMP_NN E ,EMP_NN M WHERE E.MGR=M.EMPNO) AND M.JOB!='PRESIDENT'

106) SELECT * FROM EMP WHERE DEPTNO NOT IN(SELECT E.DEPTNO FROM EMP E,DEPT D WHE RE E.DEPTNO=D.DEPTNO) OR SELECT * FROM EMP WHERE DEPTNO NOT IN(SELECT DEPTNO FROM DEPT); 107) 108) 109)SELECT * FROM EMP WHERE MOD(SAL,2) !=0 110)SELECT * FROM EMP WHERE LENGTH(SAL)=3 111)SELECT * FROM EMP WHERE TO_CHAR(HIREDATE,'MON') IN 'DEC'; 112)SELECT * FROM EMP WHERE ENAME LIKE('%A%') 113) 114)SELECT * FROM EMP_NN WHERE TO_CHAR(HIREDATE,'DD') = SUBSTR(SAL,1,2); 115)SELECT * FROM EMP_NN WHERE SAL*10/100 = TO_CHAR(HIREDATE,'YY'); 116)SELECT LOWER (SUBSTR((ENAME),1,LENGTH(ENAME)/2)) UPPER (SUBSTR((ENAME),LENGTH(ENAME)/2+1,LENGTH(ENAME))) FROM EMP_NN 117)SELECT DNAME ,COUNT(*)FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO GROUP BY DNAME HAVING LENGTH(DNAME)=COUNT(*) 118)SELECT * FROM EMP_NN WHERE TO_CHAR(HIREDATE,'DD') <=15 119)SELECT DNAME FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO GROUP BY DNAME HAVING LENGTH(DNAME) IN (SELECT COUNT(*) FROM EMP_NN E,DEPT_NN D WHERE E.DEPTNO=D.DEPTNO GROUP BY DNAME) 120)SELECT DISTINCT M.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO; 121) 122) 123) 124)SELECT ENAME,SAL,E.DEPTNO,DNAME,GRADE FROM EMP_NN E,DEPT_NN D ,SALGRADE S WH ERE E.DEPTNO=D.DEPTNO AND E.SAL BETWEEN S.LOSAL AND S.HISAL AND GRADE =(SELECT R OUND((SUM (GRADE) / 10) )FROM EMP_NN E,SALGRADE S ,DEPT_NN D WHERE E.SAL BETWEEN S.LOSAL AND S.HISAL AND E.DEPTNO=D.DEPTNO AND D.DNAME='SALES') 125) 126) 127)SELECT ENAME,SAL,'$ ' (SAL+SAL*15/100 ) "INCREMENT" FROM EMP_NN 128)SELECT ENAME '_AND_' JOB "EMP_AND_JOB" FROM EMP_NN 129)SELECT ENAME '(' JOB ')' "EMP_AND_JOB" FROM EMP_NN 130)SELECT ENAME,SAL,DEPTNO,TO_CHAR(HIREDATE,'MONTH DD YYYY') HIREDATE FROM EMP_

NN; 131)SELECT EMPNO,ENAME, SAL,CASE WHEN SAL <= 1500 THEN 'JUST SALARY' WHEN SAL > 1500 THEN 'ON TARGET' ELSE 'NO SAL' END "SAL" FROM EMP_NN; 132)SELECT TO_CHAR(TO_DATE('&DATE','DD-MON-YY'),'DAY') FROM DUAL 133)SELECT MONTHS_BETWEEN(SYSDATE,HIREDATE)/12 FROM EMP_NN 134) 135) SELECT ENAME,HIREDATE ,CASE WHEN TO_CHAR(HIREDATE,'DD')<=15 THEN NEXT_DAY(LAST_DAY(HIREDATE),'FRIDAY' ) ELSE NEXT_DAY(LAST_DAY(HIREDATE),'FRIDAY') END "PAY DATE" FROM EMP_NN; 136) 137) SELECT * FROM EMP_NN WHERE SAL!=ROUND(SAL); 138) 139)SELECT M.ENAME,M.SAL,E.ENAME,E.SAL FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPN O AND M.SAL<E.SAL 140)SELECT M.ENAME,M.SAL,E.ENAME,E.SAL FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPN O AND M.ENAME='BLAKE' 141)SELECT * FROM EMP_NN WHERE ENAME IN (SELECT M.ENAME FROM EMP_NN E,EMP_NN M W HERE E.MGR=M.EMPNO) 142)SELECT M.ENAME MANAGERS,E.ENAME EMPLOYEES FROM EMP_NN E , EMP_NN M WHERE E. MGR=M.EMPNO AND E.ENAME IN ( SELECT E.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND M.ENAME='JONES' OR E.ENAME='JONES' ) 143)DEFINE ANN_SAL=(SAL+NVL(COMM,0))*12; SELECT * FROM EMP_NN WHERE &ANN_SAL>30000; 144)SELECT COUNT(DISTINCT M.ENAME ) MANAGERS FROM EMP_NN E,EMP_NN M WHERE E.MGR= M.EMPNO 145)SELECT JOB, AVG(SAL) "AVG SAL" , AVG(SAL+NVL(COMM,0)) "AVG COMM" FROM EMP_NN GROUP BY JOB 146)SELECT * FROM EMP WHERE EMPNO IN ( SELECT EMPNO FROM EMP WHERE ROWID NOT IN( SELECT MAX(ROWID) FROM EMP GROUP BY E MPNO)) 147)SELECT * FROM EMP_NN WHERE SAL<1000 ORDER BY SAL;

148)SELECT ENAME,JOB,SAL*12 "ANNUAL SAL",E.DEPTNO,DNAME,GRADE FROM EMP_NN E,DEPT _NN D,SALGRADE S WHERE E.DEPTNO=D.DEPTNO AND E.SAL BETWEEN S.LOSAL AND S.HISAL A ND SAL*12=36000 AND JOB NOT IN 'CLERK' 149)SELECT JOB,HIREDATE,TO_CHAR(HIREDATE,'MM-YY') FROM EMP_NN WHERE TO_CHAR(HIRE DATE,'MM') <=6 AND TO_CHAR(HIREDATE,'YY') =83 AND JOB IN ( SELECT JOB FROM EMP_NN WHERE TO_CHAR(HIREDATE,'MM') <=6 AND TO_CHAR(HIREDATE,'YY') =82 ) 150)SELECT M.ENAME,E.ENAME FROM EMP_NN E,EMP_NN M WHERE E.HIREDATE<M.HIREDATE AN D E.MGR=M.EMPNO; 151)SELECT E.ENAME,M.ENAME FROM EMP_NN E,EMP_NN M WHERE E.MGR=M.EMPNO(+); 152)SELECT * FROM EMP_NN WHERE (JOB,SAL) IN (SELECT JOB,MIN(SAL) FROM EMP_NN GRO UP BY JOB); 153)SELECT * FROM EMP_NN WHERE (JOB,SAL) IN (SELECT JOB,MAX(SAL) FROM EMP_NN GRO UP BY JOB); 154)SELECT * FROM EMP_NN WHERE (DEPTNO,HIREDATE) IN (SELECT DEPTNO,MAX(HIREDATE) FROM EMP_NN GROUP BY DEPTNO); 155)SELECT ENAME,SAL,DEPTNO FROM EMP_NN WHERE SAL> ANY(SELECT AVG(SAL) FROM EMP_NN GROUP BY DEPTNO); 156)SELECT DEPTNO FROM DEPT_NN MINUS SELECT DEPTNO FROM EMP_NN 157)SELECT COUNT(*),AVG(SAL) ,DEPTNO,JOB FROM EMP_NN GROUP BY DEPTNO,JOB 158) SELECT MAX(AVG(SAL)) FROM EMP_NN WHERE JOB != 'PRESIDENT' GROUP BY JOB 159)SELECT ENAME,JOB,SAL FROM EMP_NN WHERE SAL=(SELECT MAX(SAL+NVL(COMM,0)) FROM EMP_NN) 160)SELECT ENAME,JOB,SAL FROM EMP_NN WHERE DEPTNO!=10 AND (JOB,SAL) IN (SELECT JOB,SAL FROM EMP_NN WHERE DEPTNO=10); TO FIND SECOND HIGEST SAL: ------------------------------------161)SELECT ENAME,SAL FROM EMP_NN A WHERE &N=(SELECT COUNT(DISTINCT(SAL)) FROM EM P_NN S WHERE A.SAL<=S.SAL) OR SELECT ENAME,JOB,SAL FROM EMP_NN A WHERE &N=(SELECT COUNT(DISTINCT(SAL)) FROM EMP_NN S WHERE A.SAL<=S.SAL AND JOB='SALESMAN') AND JO B='SALESMAN'; 162)SELECT DEPTNO,ENAME,JOB,SAL,NVL(COMM,0),SAL+NVL(COMM,0) NET_SAL FROM EMP_NN ORDER BY SAL DESC, NVL(COMM,0) DESC 163)SELECT DEPTNO,AVG(SAL) FROM EMP_NN GROUP BY DEPTNO HAVING AVG(SAL) <(SELECT AVG(SAL) FROM EMP_NN) 164)SELECT M.ENAME MANAGER,M.SAL MRG_SAL,E.ENAME EMPLOYEE,E.SAL EMP_SAL FROM EMP _NN E,EMP_NN M WHERE E.MGR=M.EMPNO AND E.SAL>M.SAL

165)SELECT * FROM EMP_NN WHERE DEPTNO IN ( SELECT DEPTNO FROM EMP_NN GROUP BY DE PTNO HAVING AVG(SAL) =(SELECT(MAX(AVG(SAL))) FROM EMP_NN GROUP BY DEPTNO))