Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS Assignment 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

SYMCA DIV – A

Name - Rohit Chavan Rollno.06

MCA SEM III


DBMS Practical
Assignment 5
Topic: Join Date:

Create the following Table

Employee

EMP_NO ENAME SALARY COMM HIREDATE MGR DEPTNO

Department

DEPTNO DNAME LOC


SYMCA DIV – A
Name - Rohit Chavan Rollno.06

EMPLOYEE TABLE

CREATE TABLE EMPLOYEE_22

EMP_NO NUMBER(5) CONSTRAINT PK_22_EMP_NO PRIMARY KEY,

EMP_NAME VARCHAR(20),

SALARY NUMBER(10),

COMM NUMBER(10),

HIREDATE DATE,

MGR VARCHAR(10),

DEPTNO NUMBER(10) CONSTRAINT FK_22_DEPTNO REFERENCES DEPARTMENT_22(DEPTNO)

);
SYMCA DIV – A
Name - Rohit Chavan Rollno.06

INSERT INTO EMPLOYEE_22 VALUES(101,'ROHIT',40000,15000,'05-AUG-2018','',10);

INSERT INTO EMPLOYEE_22 VALUES(102,'NISHANT',20000,5000,'05-OCT-2018','101',10);

INSERT INTO EMPLOYEE_22 VALUES(103,'YASH',36000,5050,'23-OCT-2018','101',10);

INSERT INTO EMPLOYEE_22 VALUES(104,'ADITYA',30000,500,'16-SEP-2017','',20);

INSERT INTO EMPLOYEE_22 VALUES(105,'MEHUL',35000,8000,'25-JULY-2018','104',20);

INSERT INTO EMPLOYEE_22 VALUES(106,'AJAY',38000,800,'20-AUG-2018','',30);

INSERT INTO EMPLOYEE_22 VALUES(107,'ANAND',15000,5050,'01-JAN-2018','106',30);

INSERT INTO EMPLOYEE_22 VALUES(108,'SOHAIL',15000,5050,'01-OCT-2018','107',40);


SYMCA DIV – A
Name - Rohit Chavan Rollno.06
SYMCA DIV – A
Name - Rohit Chavan Rollno.06

DEPARTMENT TABLE

CREATE TABLE DEPARTMENT_22

DEPTNO NUMBER(10) PRIMARY KEY,

DNAME VARCHAR(20),

LOC VARCHAR(10)

);
SYMCA DIV – A
Name - Rohit Chavan Rollno.06

INSERT INTO DEPARTMENT_22 VALUES(10,'HR','MUMBAI');

INSERT INTO DEPARTMENT_22 VALUES(20,'MARKETING','THANE');

INSERT INTO DEPARTMENT_22 VALUES(30,'SALES','NAVIMUMBAI');

INSERT INTO DEPARTMENT_22 VALUES(40,'PRODUCTION','MUMBAI');

INSERT INTO DEPARTMENT_22 VALUES(50,'HR','VASHI');


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

• Display all employees working in department named ‘HR’ or ‘Marketing’.

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 count of employees working.

SELECT DEPARTMENT_22.DNAME,COUNT(EMPLOYEE_22.EMP_NAME) COUNT


FROM DEPARTMENT_22,EMPLOYEE_22
WHERE EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO GROUP BY
DEPARTMENT_22.DNAME;
SYMCA DIV – A
Name - Rohit Chavan Rollno.06

• Display department name wise total salary of employees where employee is earning a
commission between 500 and 2000.

SELECT DEPARTMENT_22.DNAME,SUM(EMPLOYEE_22.SALARY) SUM


FROM DEPARTMENT_22,EMPLOYEE_22
WHERE EMPLOYEE_22.DEPTNO=DEPARTMENT_22.DEPTNO AND EMPLOYEE_22.COMM
BETWEEN 500 AND 2000
GROUP BY DEPARTMENT_22.DNAME;

• Display the name of all the managers.

SELECT DISTINCT M.EMP_NAME FROM EMPLOYEE_22 W,EMPLOYEE_22 M WHERE


W.MGR=M.EMP_NO;
SYMCA DIV – A
Name - Rohit Chavan Rollno.06

• 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;

You might also like