Company DB Values
Company DB Values
DML STATEMENTS:
DDL STATEMENTS TO ALTER THE TABLE EMPLOYEE AND DEPARTMENT DUE TO CROSS REFERENCES:
DML STATEMENTS:
S SALAR SUPERSS DN
SSN NAME ADDRESS
E Y N O
12345 Scott Housten,TX M 300000 33344 5
33344 Franklin Housten,TX M 400000 88866 5
99988 Alicia Spring,TX F 250000 98765 4
98765 Jennifer Bellaire,TX F 430000 88866 4
66688 Ramesh Humble Oak,TX M 380000 33344 5
45345 Joyce Houston,TX F 250000 33344 5
98798 Ahmad Bellaire,TX M 250000 98765 4
88866 Scott Houston,TX M 550000 1
66677 William Houston,TX M 650000 33344 5
22233 Daniel Spring,TX M 650000 88866 5
SQL> Select * from Department;
DLOC
DNO
1 Houston
4 Stafford
5 Bellaire
5 Sugarland
5 Houston
PNO HOURS
SSN
12345 1 32.5
12345 2 7.5
66688 3 40
45345 1 20
45345 2 20
33344 2 10
33344 3 10
33344 10 10
33344 20 10
99988 30 30
99988 10 10
98798 10 35
98798 30 5
98765 30 20
98765 20 15
88866 20
12345 3 15
Queries:
Make a list of all project numbers for projects that involve an employee whose last name is
‘Scott’, either as a worker or as a manager of the department that controls the project.
OUTPUT:
PNO
1
2
3
20
Show the resulting salaries if every employee working on the ‘IoT’ project is given a 10
percent raise.
OUTPUT:
Find the sum of the salaries of all employees of the ‘Accounts’ department, as well as the
maximum salary, the minimum salary, and the average salary in this department
SELECT SUM(SALARY),MAX(SALARY),MIN(SALARY),AVG(SALARY)
FROM EMPLOYEE E,DEPARTMENT D
WHERE E.DNO=D.DNO AND DNAME='Research';
OR
SELECT SUM(SALARY),MAX(SALARY),MIN(SALARY),AVG(SALARY)
FROM EMPLOYEE NATURAL JOIN DEPARTMENT
WHERE DNAME='Research';
OUTPUT:
SELECT E.NAME
FROM EMPLOYEE E
WHERE NOT EXISTS((SELECT PNO
FROM PROJECT
WHERE DNO=5)
MINUS
(SELECT PNO
FROM WORKS_ON
WHERE E.SSN=SSN));
OUTPUT:
NAME
Scott
For each department that has more than five employees, retrieve the department number
and the number of its employees who are making more than Rs. 6,00,000.
COUNT(*)
DNO
5 2