II . SCHEMA :

 

Table 1 : DEPT

 

DEPTNO (NOT NULL , NUMBER(2)),  DNAME (VARCHAR2(14)),

LOC (VARCHAR2(13)

 

Table 2 : EMP

 

EMPNO (NOT NULL , NUMBER(4)), ENAME (VARCHAR2(10)),

JOB (VARCHAR2(9)), MGR (NUMBER(4)), HIREDATE (DATE),

SAL (NUMBER(7,2)), COMM (NUMBER(7,2)), DEPTNO (NUMBER(2))

 

MGR is the empno of the employee whom the employee reports to. DEPTNO is a foreign key.

QUERIES

 

1.      List all the employees who have at least one person reporting to them.

2.      List the employee details if and only if more than 10 employees are present in department no 10.

3.      List the name of the employees with their immediate higher authority.

4.      List all the employees who do not manage any one.

5.      List the employee details whose salary is greater than the lowest salary of an employee belonging to deptno 20.

6.      List the details of the employee earning more than the highest paid manager.

7.      List the highest salary paid for each job.

8.      Find the most recently hired employee in each department.

9.      In which year did most people join the company? Display the year and the number of employees.

10.  Which department has the highest annual remuneration bill?

11.  Write a query to display a ‘*’ against the row of the most recently hired employee.

12.  Write a correlated sub-query to list out the employees who earn more than the average salary of their department.

13.  Find the nth maximum salary.

14.  Select the duplicate records (Records, which are inserted, that already exist) in the EMP table.

15.  Write a query to list the length of service of the employees (of the form n years and m months).

Advertisements