DBMS Assignment 5
DBMS Assignment 5
DBMS Assignment 5
Employee
Department
EMPLOYEE TABLE
EMP_NAME VARCHAR(20),
SALARY NUMBER(10),
COMM NUMBER(10),
HIREDATE DATE,
MGR VARCHAR(10),
);
SYMCA DIV – A
Name - Rohit Chavan Rollno.06
DEPARTMENT TABLE
DNAME VARCHAR(20),
LOC VARCHAR(10)
);
SYMCA DIV – A
Name - Rohit Chavan Rollno.06
• List all employees and department names who have been hired after 1997.
SELECT DEPARTMENT_22.DNAME,EMPLOYEE_22.*
FROM DEPARTMENT_22,EMPLOYEE_22
WHERE EXTRACT(YEAR FROM HIREDATE)>1997 AND
DEPARTMENT_22.DEPTNO=EMPLOYEE_22.DEPTNO;
• Display all department information where employee is earning a salary between 14000
and 20000.
SELECT DEPARTMENT_22.*,EMPLOYEE_22.SALARY
FROM DEPARTMENT_22,EMPLOYEE_22
WHERE (EMPLOYEE_22.SALARY BETWEEN 14000 AND 20000) AND
EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO;
SYMCA DIV – A
Name - Rohit Chavan Rollno.06
SELECT EMPLOYEE_22.*,DEPARTMENT_22.DNAME
FROM EMPLOYEE_22,DEPARTMENT_22
WHERE (DEPARTMENT_22.DNAME='HR' OR DEPARTMENT_22.DNAME='MARKETING')
AND EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO;
• Display department name wise total salary of employees where employee is earning a
commission between 500 and 2000.
• Display employee name and salary of employees whose hiredate is after January 1996
and working in sales department.
SELECT EMPLOYEE_22.EMP_NAME,EMPLOYEE_22.SALARY
FROM EMPLOYEE_22,DEPARTMENT_22
WHERE EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO AND DNAME='SALES' AND
TO_CHAR(HIREDATE,'MON YYYY')>'JAN 1996';
• Display department name wise minimum and maximum salary earned by employee
working in that department. The display should be restricted to only those department
whose maximum salary is greater than 30000.
SELECT DEPARTMENT_22.DNAME,MIN(EMPLOYEE_22.SALARY) AS
MINIMUM,MAX(EMPLOYEE_22.SALARY)AS MAXIMUM
FROM EMPLOYEE_22,DEPARTMENT_22
WHERE EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO
GROUP BY DEPARTMENT_22.DNAME HAVING MAX(EMPLOYEE_22.SALARY)>30000;