This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

By PenchalaRaju.Yanamala 001. SQL> 002. SQL> 003. SQL> 004. SQL> 005. SQL> 006. SQL> 007. SQL> 008. SQL> 009. SQL> Display all the information of the emp table. Select * from emp ; Display unique jobs from EMP table. SELECT DISTINCT Job FROM EMP GROUP BY Job ; List the details of the emps in asc order of their salaries. SELECT * FROM EMP ORDER BY Sal ASC ; List the details of the emps in asc order of the Deptnos and desc of Jobs. SELECT * FROM EMP ORDER BY Deptno ASC, Job DESC ; Display all the unique job groups in the descending order select unique job from emp order by job desc ; Display all the details of all ‘Mgrs’ select * from emp where job = 'MANAGER' ; List the emps who joined before 1981. select * from emp where hiredate < '01-Jan-1981' ; List the Empno, Ename, Sal, Daily Sal of all Employees in the ASC order of AnnSal. SELECT Empno, Ename, sal, Sal/30 DailySal FROM Emp ORDER BY Sal*12 ; Display the empno , ename, job, hiredate, exp of all Mgrs select empno, ename, sal, months_between(sysdate,hiredate)/12 Exp from emp where job = 'MANAGER' ; List the empno, ename, sal, exp of all emps working for Mgr 7839. select empno, ename, sal, months_between(sysdate,hiredate)/12 Exp from emp B where Mgr = 7839 ; Display the details of the emps whose Comm. Is more than their sal. select * from emp where comm > sal ; List the emps in the asc order of Designations select * from emp order by job ; List the emps along with their exp and daily sal is more than Rs.100

010. SQL>

011. SQL> 012. SQL> 013.

SQL> 014. SQL> 015. SQL>

Select emp.*, months_between(sysdate,hiredate)/12 Exp from emp where sal/30 > 100 ; List the emps who are either ‘CLERK’ or ‘ANALYST’ in the desc order Select * from emp where job in (‘CLERK’,‘ANALYST’) order by job desc ; List the emps who joined on 1May81,31Dec81, 17Dec81, 19Jan80 in asc order of seniority. Select ename,hiredate,months_between(sysdate,hiredate)/12 EXP from emp where hiredate like '01-MAY-81' or hiredate like '31-DEC-81' or hiredate like '17-DEC-81' or hiredate like '19-JAN-80' order by hiredate desc ; List the emps who are working for the deptno 10 or 20 Select * from emp where deptno in (10,20) ; List the emps who are joined in the year 1981 Select * from emp where hiredate like ‘%81’ ; List the emps who are joined in the month of Aug 1980 Select * from emp where hiredate like %AUG-80’ ; List the emps whose annul sal ranging from 22000 and 45000 Select * from emp where sal*12 between 22000 and 45000 ; List the emps those are having five characters in their names. Select * from emp where ename like ‘_____’ ; List the enames those are starting with ‘s’ and with fire characters Select * from emp where ename like ‘S____’ ; List the emps those are having four chars and third char must be ‘r’ Select * from emp where ename like ‘__R_’ ; List the 5 character names starting with ‘s’ and ending with ‘h’ Select * from emp where ename like ‘S___H’ ; List the emps who joined in January Select * from emp where hiredate like ‘%JAN%’ ; List the emps who joined in the month of which second character is ‘a’ Select * from emp where hiredate like ‘__-_A%’ ; List the emps whose sal is 4 digit number ending with zero Select * from emp where sal like ‘___0’ ; List the emps whose names having a character set ‘ll’ together Select * from emp where ename like ‘%LL%’ ;

016. SQL> 017. SQL> 018. SQL> 019. SQL> 020. SQL> 021. SQL> 022. SQL> 023. SQL> 024. SQL> 025. SQL> 026. SQL> 027. SQL>

List the emps who joined in any year but not belongs to the month of March Select * from emp where hiredate not like ‘%MAR%’ .DEPTNO List the empno.’MANAGER’) order by sal . SQL> 037.DEPTNO = DEPT.028. SQL> 036. ename. List the emps who joined in before or after 1981 Select * from emp where hiredate not like '%81' . List all the clerks of deptno 20. Display the location of ‘Smith’ Select loc from emp where ename = ‘SMITH’ . sal. Dept WHERE Dname IN ('ACCOUNTING'. DALLAS with an exp more than 7 years without receiving the Comma Asc order of Loc. SQL> 031. List the emps who are working under ‘Mgr’ Select * from emp where mgr in (select empno from emp where job = ‘MANAGER’) . ENAME.*. Select * from emp where deptno=20 and job =’CLERK’ . List the total information of emp table along with dname and loc of all the emps working under ‘Accounting’ & ‘Research’ in the asc deptno SELECT EMP. SQL> 039. List the emps of deptno 30 or10 joined in the year 1981 Select * from emp where deptno in(10. List the emps whose empno not starting with digit 78 Select * from emp where empno not like ‘78%’ . SQL> . DEPT WHERE LOC IN ('NEW YORK'.'DALLAS') AND JOB IN ('MANAGER'.DEPTNO ORDER BY EMP. SQL> List the emps those who joined in 80’s Select * from emp where hiredate like ‘%80’ .DEPTNO = DEPT. SQL> 035. SELECT EMPNO. dname of all the ‘Mgrs’ and ‘Analyst’ working in NEWYORK.DNAME. SQL> 029. List all the emps except ‘president’ & ‘Mgr’ in asc order of salaries Select * from emp where job not in (‘PRESIDENT’. SQL> 030.30) and hiredate like ’%81’ .SAL.DEPTNO 040. Display the details of ‘Smith’ Select * from emp where ename = ‘SMITH’ . SQL> 038.'RESEARCH') AND EMP. List the emps who does not belong to deptno 20 Select * from emp where deptno <> 20 . SQL> 033. dname FROM EMP. SQL> 032.'ANALYST') AND MONTHS_BETWEEN(SYSDATE. SQL> 034.LOC FROM Emp.HIREDATE)/12 > 7 AND COMM IS NULL AND EMP.

.grade from emp. grade from emp. dept. deptno. grade.deptno and sal between losal and hisal . salgrade where Grade between 2 and 4 and dname not like ‘OP%’ and dname not like ‘%S’ and Job like ‘%A%’ and (hiredate like ‘%81’ and hiredate not like ‘%MAR%’ and hiredate not like ‘%SEP%’) and sal not like %00 and emp.DEPTNO = DEPT. sal. SQL> 046. sal.*. 041. loc FROM EMP.DEPTNO ASC. ann sal of emps working for dept 20 or 10. but the sal should not be = 3000 or 2800 who doesn’t belongs to the Mgr and whose no is having a digit ‘7’ or ‘8’ in 3rd position in the asc order of deptno and desc order of job.ORDER BY LOC . SQL> 047. loc. loc. List the empno.2800) AND MGR IS NULL AND EMPNO LIKE '__7_' OR EMPNO LIKE '__8_' AND EMP. grade from emp.*. SQL> 044.3) and sal between losal and hisal Display all grade 4.deptno=dept.salgrade where grade in(4.5) and Job in ('ANALYST'. SQL> 045.'MANAGER') and sal between losal and hisal . List all the grade2 and grade 3 emps Select emp. Select empno. grade from emp.deptno and sal between losal and hisal List all the information of emps with loc and the grade of all the emps belong to the grade ranges from 2 to 4 working at the dept those are not starting with char set ‘OP’ and not ending with ‘S’ with the design having a char ‘a’ any where joined in the year 81 but not in the month of Mar or Sep and sal not end with ‘00’ in the asc order of grades. JOB DESC . dname. job of all emps working at CHICAGO or working for ACCOUNTING dept wit ann sal > 28000.DEPTNO. Select emp. ename. ename. sal. List the details of the depts along with empno.deptno in(10.EMP.*.5 Analyst and Mgr Select emp. salgrade where emp. SELECT EMPNO. ENAME.salgrade where grade in(2. SQL> 043.DEPTNO ORDER BY EMP. grade. months_between(sysdate. ename. DEPT WHERE (LOC = 'CHICAGO' OR DNAME = 'ACCOUNTING') AND SAL*12 > 28000 AND SAL NOT IN(3000.20) and emp.deptno=dept. sal*12 AnnSal. dept. List the empno.hiredate)/12 Exp from emp. dname. Display the total information of the emps along with grades in the asc order Select emp. dname.*. exp. ename or without the emps SQL> 042.salgrade where sal between losal and hisal . dname.JOB.SAL.

emp B where A. List the emps whose Sal is same as FORD or SMITH in desc order of Sal.deptno=dept.sal > B. List the details of the emps whose salaries more than the employee BLAKE Using self-join: select A. Select * from Emp.'SMITH') Order By sal Desc . SQL> 050.ename = 'BLAKE' Using sub-query: select * from emp where sal > (select sal from emp where ename = 'BLAKE') 049. SQL> . SQL> 056. List the emps who are Senior to ‘BLAKE’ working at CHICAGO & BOSTON. SQL> 053. SQL> 051. SQL> 055. SQL> Select empno.dept where Hiredate < 054. Note : no rows will be selected. SQL> 052. one record will be fetched.sal and B.dept where emp. ename. SQL> List the details of the emps whose job is same as ALLEN. List the emps whose Sal is > the total remuneration of the SALESMAN. List the emps whose Jobs are same as MILLER or Sal is more than ALLEN.SQL> 048.Empno = A. Select * from Emp where sal > (select SUM(sal) from emp where JOB=’SALESMAN').* from emp A. dept.Mgr) List the emps of deptno 20 whose jobs are same as deptno 10 Select * from emp where deptno=20 and job in (select job from emp where deptno=10) .deptno . select * from emp where job = (select job from emp where ename = 'ALLEN') List the emps who are senior to King select * from emp where hiredate < (select hiredate from emp where ename = 'KING') List the emps who are senior to their own MGRs select * from emp A where hiredate < (select hiredate from emp B where b. If you choose job=’CLERK’. Select * from Emp where job = (select job from emp where ename=’MILLER’) OR Sal > (select sal from emp where ename ='ALLEN') . Select distinct * from Emp where sal in (select sal from emp where ename in ('FORD'.* from emp.'SMITH')) and ename not in ('FORD'.

e) Any Grade 2&3 employee working for SALES dept or OPERATIONS dept joined in 89.'OPERATIONS') and hiredate like '%89' and sal between losal and hisal and emp.'SMITH')) and ename not in ('ALLEN'.deptno = dept. 058.4 belongs to the dept ACCOUNTING and RESEARCH whose sal is more than ALLEN and exp more than SMITH in the asc order of Exp. ’SMITH’ is the senior most in the emp table.deptno = dept. 057. b) ¾ Sal of any Mgr of Emp2 table.salgrade. SQL> 062. SQL> 063.'BOSTON') and emp.3) and dname in ('SALES'.dept. Find the details of highest paid employee. List the emps whose jobs same as ALLEN Or SMITH. Select * from Emp where job in (select distinct job from emp where ename in ('ALLEN'.dept where grade in(2.deptno .hiredate)/12 > 5) OR sal in (select sal from Emp4.'SMITH').salgrade where grade in(3. Two record will be fetched.(select hiredate from emp where ename='BLAKE') AND loc in ('CHICAGO'. SQL> . SQL> 059. Select Max(sal) from emp . Select * from emp where sal in (select sal from emp1) OR sal in (select sal*3 from Emp2 where job='MANAGER') OR sal in (select sal from Emp3 where months_between(sysdate.'RESEARCH') and Sal > (select sal from emp where ename='ALLEN') and Hiredate < (select hiredate from emp where ename='SMITH') and emp.deptno=dept. Select * from emp where sal = (select Max(sal) from emp) . If you choose ename=’TURNER’. c) The Sal of any sales person with exp of 5 yrs belongs to the sales dept of emp3 table. SQL> List the emps of Grade 3. Select * from emp where deptno = 10 and job not in (select job from emp where deptno=20) List the emps of Emp1 who are not found in deptno 20 Select * from emp where ename not in (select ename from emp where deptno=20) Find the highest Sal of the Emp table.deptno and sal between losal and hisal. SQL> 060.salgrade where grade=2 and sal between losal and hisal) OR sal in (select sal from Emp. Because.4) AND dname in ('ACCOUNTING'.deptno) List the jobs of Deptno 10 those are not found in dept 20. Write a Query to display the details of emps whose Sal is same as of a) Employee Sal of Emp1 table. d) Any Grade 2 employees of Emp4 table. Note : no rows will be selected. SQL> 061. Select * from Emp.

SQL> Find the highest paid employee of sales dept. SQL> 070. Select * from emp where sal = (select Max(sal) from emp.deptno = dept. SQL> 072.deptno ) .5) and job <> 'PRESIDENT' and Sal > (select Max(sal) from emp.salgrade where loc='NEW YORK' and Grade in (3. select * from emp where hiredate = (select min(hiredate) from emp where hiredate like '%81') . select * from emp where hiredate like '%81' and job = (select job from emp where hiredate= (select min(hiredate) from emp where hiredate like '%81')) . SQL> 065.salgrade where hiredate = (select max(hiredate) from emp where mgr= (select empno from emp where ename = 'KING')) and grade > 3 and sal between losal and hisal Find the total sal given to the ‘MGR’ select sum(sal) from emp where job = 'MANAGER' Find the total annual sal to distribute job wise in the year 81 select Job. List the details of emp belongs to New York with the Grade 3 to 5 except ‘PRESIDENT’ whose sal > the highest paid emp of CHICAGO in Group where there is ‘MANAGER’ & ‘ANALYST’ not working for Mgr KING Select * from emp.dept.* from emp.064. List the most senior emp working under KING and Grade is more than 3.deptno = dept. List the most recently hired emp of grade 3 belongs to the Loc CHICAGO Select * from emp.4.dept where dname=’SALES’ and emp. SQL> . List the emps who are senior to most recently hired emp who is working under Mgr KING Select * from emp where hiredate < (Select max(hiredate) from emp) and mgr=(select empno from emp where ename=’KING’) . SQL> 071. SQL> 066.deptno) and Mgr = (select empno from emp where ename='KING') And emp.salgrade where 067. SQL> 073.dept where loc='CHICAGO' and Job not in ('MANAGER'.dept where loc=’CHICAGO’ and hiredate = (Select max(hiredate) from emp). select grade. List the emps who joined in 81 with job same as the most senior person of year 81. SQL> 068.deptno = dept. Display the details of most senior employee belongs to 1981. select emp. sum(sal) from emp.sum(sal*12) from emp GROUP BY JOB . Display the total sal of emps belong to Grade 3.deptno and sal between losal and hisal .'ANALYST') and emp. SQL> 069.

SQL> 082. SQL> 080. SQL> 075. of emps working for those Mgrs in the asc Mgrno.deptno = emp.count(empno) from emp.SAL+(SAL*.salgrade where dept. select mgr. Display the grade.dept.2) > 3000 .job.job having count(empno) >= 2 . count(empno) from emp. SQL> .deptno group by dname having count(empno) = (select max(count(empno)) from emp group by deptno) .dept.max(sal) from emp. 077. SQL> Display the avg salaries of all CLERKS select avg(sal) from emp where job = 'CLERK' .job . count(empno). select grade. select dname. grade. List the details of the dept where the max no of emps are working select dname. Display the emps whose Mgr name is Jones Select * from emp where mgr = (select empno from emp where ename = ‘JONES’) . List the dept details where at least two emps are working.grade. no of emps where atleast two emps are ‘CLERKS’ select dname.deptno = emp. number of emps.deptno group by dname. SQL> 076. SQL> 081.deptno and sal between losal and hisal group by grade . SQL> 083. List the emps in dept 20 whose sal is > the avg sal of deptno 10 emps. Display dname.sal between losal and hisal group by grade . count(empno) from emp.deptno = emp. Display the number of emps for each job group deptno wise select dname.count(*) from emp group by mgr order by mgr asc .dept where dept. 074.deptno = emp.salgrade where dept.*. SQL> 078. count(empno) from emp. List the emps whose salary is more than 3000 after giving 20% increment Select EMP.grade having count('CLERK') >= 2 . List the Mgr no & no. max sal of each grade.deptno group by dname.dept where dept. SQL> 079.deptno and sal between losal and hisal group by dname.dept where dept.deptno = emp.2) incrsal from emp where SAL+(SAL*. select * from emp where sal > (select avg(sal) from emp where deptno=10) and deptno=20 .

loc from emp. job. sal. dept.deptno=dept.*. dname. List the emps who are not working in sales dept Select emp. SQL> 091. emp B where A. B. job. sal. SQL> 089. Manager. grade from emp. dname from emp. job. sal. salary. dname from emp. dname.sal > B. dname.salgrade where deptno in (10.deptno . select A.*. employee name for the deptno 10 or deptno 30 but salgrade is not 4 while they joined the company before ’31-DEC-82’ select grade. grade. List the emps name. List the name and salary of FORD if his salary is equal to hisal of his Grade select ename. Select ename. Mgr. SQL> 087. sal & comm.mgr=B. dname.deptno = dept. job. SQL> 093.empno and b.ename from emp A. dept where sal between 2000 and 5000 and loc = 'CHICAGO' and emp. job. sal from emp where ename = 'FORD' and sal = (select hisal from emp. SQL> 090. SQL> 088. dname from emp. SQL> List the emps with their dept names. dept. SQL> 085. SQL> .* from emp A.empno and A.deptno and sal between losal and hisal and emp.deptno . For those whose salary is between 2000 and 5000 while loc is CHICAGO Select ename. Grade dept wise.084. salgrade where ename = 'FORD' and sal between losal and hisal) List the name.*.deptno = dept.mgr = B.deptno in (select distinct deptno from emp group by emp. List the emps whose mgr name is ‘JONES’ and also list their manager name select A. SQL> 092.dept where job = 'MANAGER' and emp. select ename. List the emps whose salary is > his Manager’s salary.sal . List the grade. dept where Dname <> ‘SALES’ and emp. ename.deptno . Select emp. comm from emp. salgrade where emp.deptno . hiredate from emp. salgrade 086. dept where emp.ename='JONES' .emp B where A.ename. dept.deptno) . grade and dname except ‘CLERK’s and sort on the basis of highest salary. dname.deptno = dept.deptno = dept. loc for those who are working as a ‘MGRs’ select empno.30) and grade <> 4 and hiredate in (select hiredate from emp where hiredate < '31-DEC-82') and sal between losal and hisal List the name. job. salary. List the emps name.

A.dept where emp.deptno = dept. job and Manager who are without Manager. count(emp. List the emps whose salary is equal to average of maximum and minimum.mgr and A. dname from emp. Where at least 3 emps are working in each dept. SQL> 098.empno and A. job. SQL> 099.deptno=dept.6 + 80)) >= (select avg(sal) from emp) . sal.Empno and job = 'MANAGER') . List the names of depts. sal*12 from emp. emp B.sal + A.sal*1.comm from emp A. SQL> 101.sal and A. 097. Select ename.deptno = emp. List the names of emps who are getting the highest salary dept wise.Mgr) . SQL> List the emps name.deptno) > 3 .sal and A.sal < B. sal.2) + (A. Select dname. Select distinct A.2) -(A.empno = B. emp B where ((A.deptno in (select distinct deptno from emp group by emp. Select distinct A. 094. emp C where A. dept where emp.where job <> 'CLERK' and dept. emp B where A.deptno and sal between losal and hisal order by sal desc . Select deptno. ??? List the employee names and his annual salary dept wise. List the name. TO RETRIEVE SAL WHICH IS = TO AVG. TO RETRIEVE SAL WHICH IS = TO AVG. SQL> List the no of emps in each dept where the number is more than 3. SQL> 102.mgr not in (select empno from emp where empno <> B. job.* from emp A.sal*1.deptno and emp.deptno) from emp. SQL> 100.deptno group by dname having count(emp. job.sal > C.sal) from emp group by B. dname. count(deptno) from emp group by deptno having count(deptno) > 3 .sal > (select avg(B. mgr from emp where mgr is NULL . select ename. comm. SQL> . SAL Select ename. dept where 096.deptno) and sal in (select max(sal) from emp group by deptno) .* from emp A. A. Select ename. sal from emp where sal = (select avg(sal) from emp) .sal.sal*1. List the emps whose sal < his Manager but more than other Manager Select distinct A. SQL> 095.mgr = B. List the managers whose salary is more than his emps avg sal.ename. OF MAX SAL AND MIN SAL select * from emp where sal = (select (max(sal)+min(sal))/2 from emp) . For those emps whose net pay is > or = any other employee salary of the company.

SQL> Find out least 5 earners of the company. months_between(…)/12 giving o/p greater than 100.sal and A.deptno . List the emps who joined in the month of ‘DEC’ Select * from emp where hiredate like ‘%DEC%’ . select emp. IN BELOW QUERY I GAVE DATE() IN PLACE OF SYSDATE. ABOVE QUERY IS WORKING BUT BELOW QUERY IS NOT.hiredate)/12 > 20 order by hiredate .Mgr = B. sal*12 from emp group by deptno.hiredate)/12 Exp from emp where months_between(sysdate. comm. select count(A.deptno in (select deptno from emp group by deptno) and emp. SQL> 104. 106. SQL> 105. A. 103.emp.empno . SQL> List those emps whose sal is odd value. sal+sal*1. emp B where A.ENAME. select empno.ename <> 'PRESIDENT' AND A.sal > B.empno and B. sal. months_between('31-DEC-89'.ename. And net pay is more than any other employee. SQL> 110. select A. sal. List the enames who are retiring after ’31-DEC-89’ the max job period is 20Y.deptno = dept.Mgr = B. ename. Select empno. 109.*. SQL> 108. emp B where A. comm. SQL> 111. hiredate.job = 'MANAGER' . select * from emp where rownum < 6 order by sal asc Find out the no of emps whose salary is > their Manager salary.] select * from emp where deptno not in (select deptno from dept) 107. sysdate. Select * from emp where mod(sal. List the records from emp whose deptno is not in dept HOW CAN IT BE POSSIBLE??? [A REFERENCE KEY VALUE WITHOUT A PRIMARY KEY VALUE. months_between(sysdate.hiredate)/12 Retirement_Date from emp where months_between('31-DEC-89'. List the emps whose sal contain 3 digits Select * from emp where length(sal) = 3 .hiredate) / 12 > 20 . List the Mgrs who are not working under ‘PRESIDENT’ but are working under other Manager.JOB from emp A. OR Select deptno.2) <> 0 .2+800 Net from emp where sal = (select max(sal) from emp) .sal . ename. SQL> List the name. SQL> .empno) from emp A.

deptno having Count(empno) in (select length(dname) from dept group by dname) group by emp. sal * . [AT PRESENT THERE ARE 6 EMPS] IF U DON’T CHANGE THE ABOVE.1.1.deptno 114. select dname.2) . OF EMPS = NO OF CHARS IN THE DNAME.deptno from emp.(length(ename)/2)+1. U GET THE WRONG O/P FOR THE SAME.deptno from emp.deptno = dept. SQL> List the emps whose names contains ‘A’ select ename from emp where ename like '%A%' . I HAD TO CHANGE ONE SALES DEPT(DEPTNO 30) EMP TO SOME OTHER DEPT – SO THAT THE NO OF CHARS IN SALES DEPT(5) IS = NO OF EMPS OF THAT DEPT. hiredate from emp where sal * .deptno having Count(empno) in (select length(dname) from dept group by dname) group by emp.length(ename))) from emp . hiredate from emp where substr(hiredate. dept where emp. count(empno) from emp. List first 50% of chars of ename in lower case and remaining are upper case. List the emps whose first 2 chars from hiredate = last 2 chars of salary.sal . O/P : Reserch .112. 8 Which is a wrong O/P.length(hiredate)-1. select dname.2) = deptno or substr(sal.length(ename)/2)).length(sal)-1.length(sal)-2. AT PRESET THERE ARE NO SUCH DNAME WHERE NO. deptno from emp where substr(sal.2) = deptno or substr(sal. SQL> 117.2) = substr(sal.length(sal)-1. List the dname whose no of emps is = to no of chars in the dname.deptno) . sal. upper(substr(ename. dept where emp.1.deptno = dept. select ename. SQL> 116.deptno) .length(sal)-3. SQL> 113. select dname. select ename. SQL> . List the emps whose 10% of sal is equal to year of Joining select ename.2) . dept where emp. SQL> 115. TO GET THE OUTPUT. length(dname) Len from dept where deptno = (select emp. lower(substr(ename. THIS QUERY WILL WORK AFTER MODIFING EMP TABLE.1 like substr(hiredate. length(dname) Len from dept where deptno = (select emp. sal. List the emps whose deptno is available in his salary. select ename.deptno = dept.2) = deptno .

deptno. 122.deptno = dept. length(dname) Len from dept where deptno IN (select emp. SQL> 123. SQL> List the emps who are working as managers select * from emp where empno in (select mgr from emp) . SQL> 124.118. Count the no of emps who are working as ‘Managers’ (using set option) Select * from emp where empno in (select empno from emp) Union (select Mgr from emp) GIVING ERROR : ‘Query block has incorrect number of result columns’ List the emps who joined in the company on the same date select * from emp where hiredate in (select hiredate from emp having count(hiredate) > 1 group by hiredate) . select * from emp where hiredate in (select hiredate from emp where hiredate > (select hiredate from emp where hiredate like '14-%')) . select * from emp. SQL> 121.deptno) . count of emps List the emps those who joined in company before 15th of the month. NO ROWS SELECTED 119.deptno having Count(empno) in (select count(empno) from emp group by deptno) group by emp. no of chars of which is no of emp’s in any other dept ??? select dname. salgrade where grade = deptno/10 and deptno = (select deptno from dept where dname='SALES') and sal between losal and hisal . 120. length(dname) from dept . count(empno) from emp.deptno = dept. dname . List the name of dept where highest no of emps are working select dname.deptno having count(empno) = (select max(count(empno)) from emp group by deptno) group by emp.deptno from emp. SQL> List the dname. SQL> group by dname . select dname. SQL> .deptno. O/P : Dname. dept where emp. emp. List the details of the emps whose grade is equal to one tenth of sales dept. dept where emp.

') from emp . count(empno) from emp2. SQL> select ename.deptno = dept. Write a query to return the day of the week for any date entered in . 128. dname having count(empno) >= (select count(deptno) from dept) .YYYY.(sal>1500). List the emps with hiredate in format June 4. dept where emp2. List the ename and sal is increased by 15% and expressed as no of dollars. sal + sal * 0. SQL> 129.OR select * from emp.deptno) and emp2.'Below 1500'.15. no of emps are working select dname. 'just salary'. MISSING RIGHT PARENTHESIS.deptno.(sal<1500).deptno group by dept.15)/34) NewSal from emp .deptno. decode(sal. 125. 132. SQL> 131. sal. select ename. SQL> 127. salgrade where grade = deptno/10 and sal between losal and hisal . dept. Produce the following output from EMP EMPLOYEE ---------------SMITH(clerk) ALLEN(salesman) select ename || '(' || lower(job) ||')' EMPLOYEE from emp . (sal + sal * 0. 1500.15). ‘On target’ if salary is 1500 and ‘Below 1500’ if salary is less than 1500. SQL> 130.'On target'. (sal + sal * 0.1988. Produce the output of EMP table ‘EMP_AND_JOB’ for ename and job select ename || '_AND_' || job from emp . List the managers name who is having max no of emps working under him select ename from emp where empno = (select mgr from emp having count(empno) = (select max(count(empno)) from emp group by mgr) group by mgr) .sal) from emp .deptno in (select deptno from emp group by emp.'Month DD. 126. to_char(hiredate. SQL> List the name of the dept where more than avg. Print a list of emp’s listing ‘just salary’ if salary is more than 1500. decode(sal. SQL> select ename.

Find out the emps who are getting decimal value in their sal without using like operator. . SQL> 140. Count the no of characters without considering spaces for each name. SQL> 141. select * from emp where mgr = (select empno from emp where ename='BLAKE') .1)) ='. length(ename) from emp . Print the details of all the emps who are sub-ordinates to BLAKE. Use the following values to test your solution. SQL> 136. sal.empno and A. OR select to_char(sysdate. List the emps who are working as managers using co-related subquery Using Sub Query : Select * from emp where empno in(select mgr from emp) . Select ename.' 138. SQL> 137. Those hired after 15th are paid on the first Friday of the following month. SQL> 134.1)) from emp . Print a list of emps.Mgr=B. ‘12/34’. select distinct B. SQL> 135. Print the expression ‘YES’ if valid. SQL> 139. SQL> List those emps whose salary contains first four digit of their deptno. emp B where A. 'day') from emp . ‘NO’ if not valid.sal . sal from emp where to_char(substr(to_char(sal). 'day') from dual Wrote a query to calculate the length of service of any employee with the company.-3. their hiredate and the first pay date. Sort on hiredate.sal > B. ‘99/98’ Emps hired on or before 15th of any month are paid on the last Friday of that month.* from emp A. 133. ‘01/la’. to_char(substr(to_char(sal). verify that the first and last two characters are numbers and that the middle character is ‘/’.3. use DEFINE to avoid repetitive typing of functions DEFINE ???? Give a string of format ‘NN/NN’. Select ename. SQL> Select ename.SQL> format ‘DD-MM-YY’ select to_char(hiredate. ??? ?????????? salary contains first four digit of their deptno ????? List those managers who are getting less than his emps salary.

B. sort the output by salary. grade from emp. OR Select job. SQL> 145. select distinct A. Define a variable representing the expression used to calculate on emps total annual remuneration.null.mgr from emp) 142. Select * from emp where sal < 1000 order by sal .* from emp A.mgr = (select empno from emp where ename='JONES') and B. and grade who earn 36000 a year or who are not CLERKS. sal*12 AnnSal. Select ename.deptno. sum(decode(comm. Remember salesman earn commission. SQL> 144. SQL> 148. avg(sal). List the employee name. Find out how many managers are there in the company. emp B where A.ename='JONES' .empno =B.* from emp A. emp B where A. Find avg sal and avg total remuneration for each job type.null. Use the variable in a statement which finds all emps who can earn 30000 a year or more. job. salgrade where sal*12 > 36000 and job <> 'CLERK' and sal between losal and hisal and dept. sal*12 Ann_Sal from emp where sal*12 >= 30000 . emp. annual sal.empno in(select B. dept. SQL> . avg(decode(comm.Mgr . ??? List the emps who are drawing less than 1000. job.0)+sal) from emp group by job . SQL> 149.0)+sal) from emp group by job . sum(decode(comm. Using Co-Releated Sub Query : Select distinct A. Select count(*) from emp where empno in(select mgr from emp) . Select job. dname.Using Co-Releated Query : Select distinct A. SQL> List the emps whose Mgr name is ‘JONES’ and also with his Manager Name. SQL> 147.ename from emp A. OR Select job.*.null. sum(sal) from emp group by job . 143.deptno . Find out the job that was filled in the first half of 1983 and same job that was filled during the same period of 1984. dept name. count(empno). SQL> Check whether all the emps numbers are indeed unique. select emp.deptno = emp.avg(sal). emp B where A. deptno.*.0)+sal). 146.

Find out the most recently hired emps in each dept order by hiredate select * from emp where hiredate in (select max(hiredate) from emp group by job) order by hiredate desc . B. deptno from emp where sal in (select sal from emp where sal > (select avg(sal) from emp .hiredate . HOW TO RETRIEVE KING’S INFO select * from emp where empno in (select distinct A. SQL> select ename.ename from emp A. Sort in des order of sal select * from emp where sal in (select max(sal) from emp group by job) order by sal desc .mgr = B. emp B where A. ERRRO : Query Block has incorrect number of result columns.mgr = B.empno.select job from emp where hiredate in (select hiredate from emp where hiredate > '01-JUL-82') and hiredate in (select hiredate from emp where hiredate > '01-JUL-84') NO ROWS SELECTED 150.hiredate < B. SQL> 151. emp B where A. B. List the emp name. sal and deptno for each emp who earns a sal greater than the avg for their dept order by deptno 152.empno. select A. A.empno) union (select B. SQL> 154.empno . Find all the emps who earn minimum sal for each job wise in asc order of sal select * from emp where sal in (select min(sal) from emp group by job) order by sal . sal.empno. emp B where A.mgr from emp A. SQL> Find out the emps who joined in the company before their managers. Find out all the emps who earn highest sal in each job type. List all the emps by name and number along with their manager’s name and number also list KING who has no ‘Manager’ select distinct A.empno from emp B where ename='KING') . A. SQL> 153.ename.mgr. A.mgr = B. A.empno from emp A. SQL> 155.empno and A.hiredate.

0) 160.0)) from emp where sal+decode(comm.null. job. deptno from emp where sal = (select max(sal) from emp where sal in (select sal from emp where sal < (select max(sal) from emp))) . max(sal). job.0) = (select max(sal+decode(comm.null.null. sal. NO SUCH RECORDS. SQL> List the deptno where there are no emps select deptno. job. sal from emp where deptno <> 10 and job in (select job from emp where deptno=10) or sal in (select sal from emp where deptno=10) .group by deptno) group by deptno) order by deptno NOT A GROUP BY EXPRESSION 156. job and salary of the emps who are not belonging to the dept 10 but who have the same job and salary as the emps of dept 10.0) < (select max(sal+decode(comm.0). 161. dname from dept where deptno not in (select deptno from emp) . SQL> 157. deptno from emp where sal+comm = (select max(sal+decode(comm. Find the max avg salary drawn for each job except for ‘PRESIDENT’ select job.null. name. Select ename.null. job.null. job. SQL> .0) in (select sal+decode(comm. sal. job. avg(sal) from emp where job <> 'PRESIDENT' group by job .0). avg(sal) from emp group by deptno. sal. job. Find the name and job of the emps who earn Max salary and Commission. deptno from emp where empno = (select empno from emp where sal+decode(comm. List the name.0)) from emp)))) .0) in (select sal+decode(comm.0) from emp where sal+decode(comm. sal. SO GIVE : select ename. sal+comm. Select ename. sal from emp where deptno <> 10 and job in (select job from emp where deptno=10) and sal in (select sal from emp where deptno=10) .null. sal+decode(comm. select ename. List the no of emps and avg salary within each dept for each job. select deptno. salary and sal+comm.null.null. Of the emps who earn the second highest earnings (sal+comm) select ename. job. SQL> 158 SQL> 159. select ename. job . comm from emp where sal=(select max(sal) from emp) or comm=(select max(comm) from emp) .null. SQL> List the deptno. count(empno). sal+decode(comm.0)) from emp where sal+decode(comm.null.

B. SQL> 163. SQL> 168. SQL> 165. ename. B.deptno = (select deptno from emp having count(deptno) = 1 group by deptno) .ename. A. comm From emp . select ename. sal. empno desc . select dname.ename. select A. job. Select * from emp where ename = ‘BLAKE’ .0)) from emp))) 162. emp B where A. List the dept in asc order of job and the desc order of emps print empno. of emps Select empno.mgr = B. List the details of the emps in the asc order of salary. SQL> 166. deptno from emp order by job.empno and A. select * from emp where deptno = (select deptno from emp having count(deptno) = 1 group by deptno). avg(sal) from emp having avg(sal) = (select min(avg(sal)) from emp having avg(sal) in (select avg(sal) from emp group by deptno) group by deptno) group by deptno .null. job.sal. SQL> Display the unique dept with jobs. salary and sal+comm. sal from emp where sal >= (select max(avg(sal)) from emp group by deptno) . name. 164. 170.0) < (select max(sal+decode(comm. sal of the emps in the department with the highest avg sal. SQL> 171. job. ename select empno. job.null.job from emp. sal. Select * from emp order by sal . List the empno. List out the names and salaries of the emps along with their manager names and salaries for those emps who earn more salary than their manager. dept where emp. sal. SQL> .sal . Display the unique dept of emps. job. SQL> 167.sal from emp A. Of the salesman select ename. deptno from emp where job = 'SALESMAN' List the deptno and their avg salaries for dept with the avg salary less than the avg for all departments. SQL> 169. SQL> NO ROWS SELECTED List the deptno. sal and comm.sal > B.from emp where sal+decode(comm. Display the details of BLAKE. List out the name. comm. select deptno. To get the answer enter a new record with deptno as 40.

SQL> 176. sal*. SQL> 173. List all emps joined on 1 May 81.sal. hiredate. select * from emp where months_between(sysdate. DA 40%. SQL> . List the emps whose ann sal is < 25000 in the asc order of salaries Select * from emp where sal*12 < 25000 order by sal .sal*.hiredate from emp where hiredate < '01APR-81' 177. SQL> 178. SQL> 174. current date & exp in the asc order of exp.3 TA. ename. 80 IT. SQL> List all CLERKs Select * from emp where job = ‘CLERK’ .2 Gross. ename. Select empno.2 .sal*. ann sal. Ename. sal*1. sysdate. Select empno. sal/30 DailySal from emp where job = ‘SALESMAN’ order by sal . SQL> 179. deptno of dept 10 emps in the asc order of sal.4 DA. ename.2 NetAllowances. List the emps whose exp is more than 10 years. SQL> 181. gross.hiredate)/12 > 10 . Select * from emp where sal < 3500 .hiredate)/12 Exp from emp order by hiredate . sal*12 AnnSal. List the empno. sal+sal*1.172. List the emps whose salaries are less than 3500.sal. SQL> 175. List the emps Empno. Select * from emp where hiredate = ’01-MAY-81’ . LIC.sal.16)-80 NetDeductions.(sal*. (sal*. Ename. net deductions. 180. months_between(sysdate. SQL> Giving wrong output.sal TA 30%.12 PF. (sal+sal*1.sal*. List the empno.sal for all emp joined before 1 apr 81 Select Empno. daily sal of all salesman in the asc ann sal. hiredate.sal.sal. List the empno. PF. ename. Select empno. ename. deptno from emp where deptno = 10 order by sal . List empno. sal*. HRA 50%.5 HRA. ename. Select Empno.hiredate from emp where hiredate in ( select hiredate from emp where hiredate > '01-APR-81') .16)-80) NetSal from emp order by sal . ename. select empno. net allowances and net sal in the asc order of net sal. Ename. ename.04 LIC.

THERE IS NO SUCH HIREDATES 185. '30_DEC-81') . THERE IS NO SUCH EMPs. 7890. NO ROWS WILL BE SELECTED. NO ROWS WILL BE SELECTED. List the names start with ‘M’ Select ename from emp where ename like 'M%' List the emps who joined in the year 81 . 30 dec 81. Select * from emp where hiredate in (select hiredate from emp where hiredate > '30-JUN-82') . Select * from emp where job = ‘MANAGER’ or job = ‘CLERK’. SQL> NO ROWS SELECTED List all the 4 chars emps. select * from emp where hiredate like '%81' . Select * from emp where hiredate > '30-JUN-82'. 7654. SQL> 193. '17-NOV-81'. select * from emp where hiredate in ('01-MAY-81'. List the emps names end with ‘H’ all together 5 chars. 17 nov 81. List the emps who joined in the following dates : 1 may 81. SQL> 186. List the emps names starting with ‘M’ with 5 chars Select ename from emp where ename like ‘M____’ . SQL> 192. 7900) .182. List the emps working under the Mgrs 7369. SQL> 190. List the emps whose ann sal ranging from 23000 to 40000. Select ename from emp having length(ename) = 4 group by ename . THERE IS NO SUCH EMPNOs 188. SQL> 184. 191. Select * from emp where Mgr in (7369. GIVE ONE MORE ‘_’ IN ENAME. Select ename from emp where ename like '____H' . 7890. SQL> List the emps who are working as Mgrs. SQL> List the emps who joined in year 81. SQL> 187. SQL> 183. SQL> List the emps who joined in the second half of 82. NO ROWS WILL BE SELECTED. Select * from emp where job = ‘MANAGER’ . 7654. List the emps who are either CLERKs or MANAGERs. 189. Select * from emp where sal*12 between 23000 and 40000 . 7900.

’ List the emps who joined in the month having a second char is ‘A’ Select * from emp where hiredate like ‘%-_A%’ . select * from emp where deptno in (10.. select emp. SQL> 198. SQL> 201.20) order by job desc . List the emps whose sal is ending with 00. SQL> 200.'ANALYST') and sal between 2000 and 5000 and comm is null .SQL> 194. job of emps with the ann sal < 34000 but receiving some comm. SQL> 204. List the Mgrs of dept 10 or 20. SQL> 195. List the emps who are working as either mgr or analyst with sal ranging from 2000 and 5000 and without comm. sal. List the emps who joined in the month having a char ‘a’ Select * from emp where hiredate like ‘%A% . SQL> 206. SQL> 197. CHECK OUTPUT. List the emps who joined in 80’s. SQL> Select * from emp where hiredate like ‘%81’ . SQL> 203. Select * from emp where hiredate like ‘%JAN%’ and Sal between 1500 and 4000 . Select * from emp where hiredate like ‘%8_’ .hiredate)/12 > 8 . SQL> 196. Select * from emp where sal like ‘%00’ . select * from emp where JOB IN ('MANAGER'. List the emps joined in Jan with salary ranging from 1500 to 4000. DATE IS GIVING WRONG RESULT. List the emps who are either clerks with an exp more than 8y Select * from emp where job = ‘CLERK’ or Months_between(sysdate. List the unique jobs of depts..20) and job = 'MANAGER' .hiredate)/12 Exp from emp where mgr like '7%' and mgr not like '%9%' and hiredate < (select '01-Jan-83' from dual) .*. SQL> 199. List the empno. List the emps along with the exp of those working under the mgr whose no is starting with 7 but should not have a digit 9 joined before 1983. months_between(sysdate. Select * from emp where sal like ‘____’ . List the emps whose salary is 4 digit no. 205. List the emps who joined in the month of jan Select * from emp where hiredate like ‘%JAN%’ . ename. Which should not be > sal and designation . SQL> 202. 20 or 30 in des order select distinct job from emp where deptno in (10.

sal. APR & SEP and working for mgrs & no is not ending with 88 or 56.deptno ..deptno = emp. 207. [???] select empno.20) and job IN ('CLERK'. deptno. SQL> 208.dept.deptno. SQL> 209. with a job not ending with ‘MAN’ but sal > 850 or the emps working for dept 30 with a job having a char ‘A’ irrespective of the position with comm.deptno .hiredate)/12 between 6 and 10) and mgr is not null and comm is null and job not like '%MAN' and sal > 850) or (deptno = 30 and job like '%A%' and comm > 200 and months_between(sysdate. List the empno. months_between(sysdate. > 200 with exp >= 7y and sal < 2500 but not belongs to the month SEP or NOV working under the Mgr whose no is not having digits either 9 or 0 in the asc dept & desc dept.SQL> should be salesman working for dept 30.hiredate)/12 >= 7 and sal < 2500 and hiredate not in (select hiredate from emp where hiredate like '%SEP%' or hiredate like '%NOV%') and mgr in (select empno from emp where empno not like '%9%' or empno like '%0%')) order by deptno desc NO ROWS SELECTED List the details of emps working at CHICAGO. loc of all emps Select empno. ename. sal.loc from emp. ename. job.dept where loc = ‘CHICAGO’ and Dept. ename.4) and months_between(sysdate. job from emp where sal*12 < 34000 and comm is not null and comm < sal and job = 'SALESMAN' and deptno=30 . List the empno.ename.deptno = emp. SQL> 210.'ANALYST') and length(sal) in (3.hiredate)/12 Exp from emp where (deptno in (10. SQL> . job. but not belongs to months of MAR. sal. select * from emp where deptno in (10. select empno.dept where Dept. ename. List the emps who are working for dept 10 or 20 with desigs as CLERK or analyst with a sal is either 3 or 4 digits with an exp > 8y.20) and (months_between(sysdate. deptno & exp of all emps belongs to dept 10 or 20 with an exp 6 to 10 yrs working under some mgr without comm.deptno.hiredate)/12 > 8 and hiredate not in (select hiredate from emp where hiredate like '%MAR%' or hiredate like '%APR%' or hiredate like '%SEP%') and mgr is not null and empno not in (select empno from emp where empno like '%88' or empno like '%56') . Select * from emp.

deptno = emp.deptno and sal between losal and hisal .5) and months_between(sysdate. SQL> 216.deptno = dept. Select ename.loc from emp. SQL> 217.deptno and sal between losal and hisal . List the empno.salgrade where Job = ‘CHICAGO’ and grade in (2.'DALLAS') and sal between 2000 and 5000 and hiredate like '%81' and Emp.'ALLEN') and Emp. grade. dname of all depts. 10 or 20. loc from emp. Joined after 1987 and whose names should not be either miller or allen. new york with sal ranging from 2000 to 5000 joined in 81.deptno . SQL> . dept where Loc in ('CHICAGO'. DALLAS with an exp> 6yrs. Select empno.deptno = dept.dept where Deptno in (10.'ALLEN') and Emp.211.deptno = dept. sal. List the emps along with loc of those who belongs to Dallas.hiredate)/12 > 6 and Emp. SQL> 215.deptno and sal between losal and hisal . job from emp. ename.20) and Dept. Select ename.'OPERATIONS'. SQL> 214. List the grade 2&3 emp of Chicago Select emp. Select empno. List the empno.ename. sal. SQL> 212. List the grade 3 emps of research & operations depts. NO SUCH RECORDS.* from emp.hiredate)/12 > 6 and Emp. Select ename. sal.deptno = dept. dept where Loc in ('NEW YORK'. loc from emp. grade from emp. grade. dname. SO GIVE : Select ename. Select empno.4. loc.3) and sal between losal and hisal . ename. dept. sal.deptno = dept. ename. loc. List the emps with loc & grade of accounting dept or the locs Dallas or Chicago with the grades 3 to 5 & exp > 6y.deptno . loc. salgrade Where sal between losal and hisal . dname. salgrade where job = 'ACCOUNTING' or Loc in ('chicago'.'DALLAS') and Months_between(sysdate. loc.'SALES') and hiredate in (select hiredate from emp where hiredate < '31-DEC-87') and ename not in ('MILLER'. dept. salgrade where grade = 3 and dname in ('RESEARCH'. job from emp. grade of all emps.'DALLAS') and grade in (3. salgrade where grade = 3 and dname in ('RESEARCH'. loc of all emps working at CHICAGO. 213.'OPERATIONS') and hiredate in (select hiredate from emp where hiredate > '31-DEC-87') and ename not in ('MILLER'.deptno . SQL> List the empno.dname. grade from emp. dept.

SQL> List the Mgrs who are senior to king & who are junior to smith. salgrade Where grade > (select grade from emp. emp B where A. List the emps who belongs to dept 10 and sal > allen’s sal Select A.hiredate < (select B.sal > (select sal from emp where B.sal > (select sal from emp where B. grade from emp. List the emps who are senior to miller. SQL> List the emps whose job is same as smith. emp B where A. emp B where A. SQL> 222.ename = 'BLAKE' and emp. SQL> 224. SQL> 226. ename. SQL> .deptno and sal between losal and hisal List the emps whose grade are > the grade of miller.hiredate . sal. Select emp.empno and A. dname.empno=B. salgrade Where ename = 'MILLER' and sal between losal and hisal) and sal between losal and hisal 225.empno) . Select * from emp where hiredate < (select hiredate from emp where ename = 'MILLER') .218. salgrade Where emp. SQL> 220. List the emps who are senior to their own mgr. Select A.empno) order by A.hiredate from emp where empno = B.empno=B. loc from emp.deptno = (select deptno from emp where ename='KING') and emp. Select * from emp where job = 'MANAGER' and hiredate < (select hiredate from emp where ename = 'KING') and hiredate > (select hiredate from emp where ename = 'SMITH') . OR select * from emp where deptno= 10 and sal > (select sal from emp where ename='ALLEN') . SQL> 219. List the emps whose sal > blake’s Select A.mgr = B. ename.deptno = 10 and A. dept. dname.ename = 'ALLEN' and emp.* from emp A. SQL> 223. sal.*. List the empno.loc of all the emps belong to king’s dept Select empno.empno) .* from emp A. 221.* from emp A.deptno = dept. loc. List the emps whose job is same as either allen or sal > allen Select * from emp where ename <> 'ALLEN' AND (job = (select job from emp where ename = 'ALLEN') or sal > (select sal from emp where ename = 'ALLEN')) . Select * from emp where job = (select job from emp where ename=’SMITH’) .

0) from emp2. GIVING ERROR : ‘Query block has incorrect no.) of all sales person of sales dept belongs to emp2 table.‘ 228.deptno) or sal in (select sal from emp4. d) Any grade 4 emps sal of emp4 table e) Any emp sal of emp5 table Select * from emp Where sal in (select sal from emp1 where job = 'CLERK') or sal in (select sal from emp2 where hiredate > '01-JAN-83' ) or sal in (select sal+decode(comm. Select * from emp where sal in (select sal from emp where ename in(‘FORD’.‘ List the highest paid emp Select * from emp where sal = (select max(sal) from emp) .deptno and sal between losal and hisal .’BLAKE’)) . Select * from emp where sal in (select sal from emp where ename = 'FORD') UNION (select sal from emp where ename = 'BLAKE') . salgrade Where loc in ('DALLAS'. Select * from emp Where sal in (select sal from emp1 where job = 'CLERK') union (select sal from emp2 where hiredate > '01-JAN-83' ) union (select sal+decode(comm.dept where dname='SALES' and emp2.0) from emp2. of result columns.227. GIVING ERROR : ‘Query block has incorrect no.dept where dname='SALES' and emp2.deptno) union (select sal from emp4.null. of result columns.deptno=dept.salgrade where ename='ADAMS' and sal between losal and hisal) or months_between(sysdate.hiredate)/12 from emp where ename = 'SMITH')) and ename not in ('ADAMS'. List the details of most recently hired emp of dept 30. Select * from emp where hiredate = (select max(hiredate) from emp where deptno = 30) and deptno = 30. b) Any emp of emp2 joined before 83. SQL> 229.'SMITH') and emp. List the emps whose sal is same as ford or blake.null. SQL> 231. SQL> List the emps whose sal is same as any one of the following: a) Sal of any clerk of emp1 table. SQL> List the emps who are belongs to dallas or Chicago with the grade same as adams or exp more than smith.deptno = dept.'CHICAGO') and (grade = (select grade from emp. SQL> . 230. dept.deptno=dept. c) The total remuneration (Sal+comm.hiredate)/12 > (select months_between(sysdate.salgrade where grade=4) or sal in (select sal from emp5) . Select * from emp.salgrade where grade=4) union (select sal from emp5) .

SQL> .loc from emp.salgrade. SQL> List the highest paid emp working under king.salgrade.deptno = dept.dept.*.dept where hiredate < (select max(hiredate) from emp where hiredate in (select hiredate from emp where hiredate < (select max(hiredate) from emp. END OF BOOK QUERIES List the second highest paid emp Select * from emp where sal = (select max(sal) from emp where sal in (select sal from emp where sal < (select max(sal) from emp))) .'01-JAN-83') from dual . 234.deptno))) and loc = 'CHICAGO' and emp. select greatest(sysdate.deptno = dept.232. Select * from emp where sal = (select max(sal) from emp where mgr=(select empno from emp where ename='KING')) . Find the oldest date between current date and ‘01_JAN-83’.dept where loc = 'CHICAGO' and grade=2 and sal between losal and hisal and emp.deptno))) and loc = 'CHICAGO' and grade=2 and emp.dept where loc = 'CHICAGO' and grade=2 and sal between losal and hisal and emp.loc from emp. SQL> 235.deptno SPENT 40 MINUTES ON THE ABOVE QUERY 233. select emp.deptno and sal between losal and hisal OR select emp.*.salgrade where hiredate < (select max(hiredate) from emp where hiredate in (select hiredate from emp where hiredate < (select max(hiredate) from emp.deptno = dept.deptno = dept. SQL> List the highest paid emp of Chicago joined before the most recently hired emp of grade 2.

- OTL - Implementation Steps
- SQL- Queires Asked in Interviews
- Question a Ire
- SQL Queries
- SQL File
- SQL Queries Answers
- California Tax Board
- Assignment 2(SQL)
- JobBrokersCenter.doc
- SQL Queries
- final ppt
- SQL Queries
- 12-063 Computer Operator (Internal)
- OOracle Emp Table Script
- SQL Exercises
- SQL Assignements[1]
- Full Physical Report
- Oracle Queries
- Advanced UI Techniques E-Learning Course Transcript(1)
- SQL- Useful Questions & Answers
- Plsql Tables
- S Q L - NOTES
- Join
- 6049607-SQL-ASSIGNMENTQUERIES
- Creating a Simple Table View
- PLSQL Programs
- DBMS
- SQL Queries for Practice
- Aetna Database Devloper
- Oracle SQL Queries on Sales Table

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd