Assignment 3
Assignment 3
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.
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;
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
**********************