0% found this document useful (0 votes)
36 views2 pages

Assignment 3

Uploaded by

Sarthak Mittal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Assignment 3

Uploaded by

Sarthak Mittal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment No.

1. Count the number of employees working in each department having salary greater
than 30000.
a. select count(empid), dno from emp123 where salary > 3000 group by dno;
2. List the name, doj and job of all employees working in the sales department.
a. select * from emp123 e, department d where e.dno = d.dno;
b. select * from emp123 e right join department d on e.dno=d.dno;
c. select * from emp123 e right join department d on e.dno=d.dno where
dname='Research';
d. select ename, date_of_joining, dno from emp123 where dno=(select
dno from department where dname like 'Research');
3. List the employee numbers, names, department numbers and the department
name.
a.

4. Display the list of employees working in each department. Display the department
information even if no employee belongs to that department.

5. List the supervisee names along with their supervisor’s name.


a. First we break emp 123 table into two tables
b. select m.ename "Supervisor", e.ename "Supervisee" from emp123 m,
emp123 e where m.empid = e.mgrid;

6. List all employees who joined the company before their managers.
a. select e.ename as employees, m.ename as managers from emp123 e ,
emp123 m where e.mgrid=m.empid and e.date_of_joining <
m.date_of_joining;

7. Display the different designations in department no 2 and 3.


a. select distinct(job) from emp123 where dno in (1,4)

8. List the jobs common to department 2 and 3.


a. select job from emp123 where dno=1 union select job from emp123 where
dno=3;
b. select job from emp123 where dno=1 intersect select job from emp123
where dno=4;

9. List the employees belonging to the department of Vijay.


a. We will use sub query (it is a nested query)
b. Output of other query will be input of other query
c. select * from emp123 where dno= (select dno from emp123 where ename
like 'Ayush');
10. List the job with highest average salary.
a. From every department caculate average and max average of department
b. select max(avg(salary)) from emp123 group by job;
c. select job, avg(salary) from emp123 group by job having avg(salary) =
(select max(avg(salary)) from emp123 group by job);
11. List the names of the employees, who earn lowest salary in each department.
a. select min(salary) from emp123 group by dno;
b. select ename, salary from emp123 where salary in (select min(salary) from
emp123 group by dno);
c. select t1.ename, t1.salary from emp123 t1 join (select min(salary)
salary, dno from emp123 group by dno) t2 on t1.salary = t2.salary and
t1.dno=t2.dno;

12. List employee details who earn salary greater than the average salary for their
department.
a. select empid,dno,salary from emp123 e where salary > (select avg(salary)
from emp123 e2 where e2.dno=e.dno);

13. List employee details whose salary is greater than average salary of all the
employees joined before 1st April 1981.
14. Select nth highest salary from employee table
a. Row id (attribute)
b. Rownum – hidden rows
c. select rownum from emp123 where empid=5; - the value of rownum will
always be 1
d. select * from (select rownum rn, ename, salary from (select * from
emp123 order by salary desc)) where rn=3;
15. Count the number of employees working in each department

**********************

You might also like