Professional Documents
Culture Documents
Exp14 Case Study1 Company Dtabase
Exp14 Case Study1 Company Dtabase
Exp14 Case Study1 Company Dtabase
SCHEMA DIAGRAM:
ER DIAGRAM:
Write and Execute the SQL Queries for the following statements:
1. Make a list of all project numbers for projects that involve an employee whose last name
is ‘Ganesh’, either as a worker or as a manager of the department that controls the project.
2. Show the resulting salaries if every employee working on the ‘IoT’ project is given a 10
percent raise.
3. 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(E.SALARY), MAX(E.SALARY), MIN(E.SALARY), AVG(E.SALARY)
FROM EMPLOYEE E JOIN WORKS_FOR W ON(E.SSN=W.SSN) JOIN DEPARTMENT D
ON(W.DNO=D.DNO) WHERE D.DNAME='RESEARCH';
4. For each project on which more than ONE employee(s) work, retrieve the project
number, the project name, and the number of employees who work on the project.
5. For each project, retrieve the project number, the project name, and the number of
employees from department 3 who work on the project.
7. Display the count of Male and Female Employees working for Department 2.
11. Display SSN, Name and Age of Employees working on Project 501.
12. Display SSN, Name and Age of Employees NOT working on Project 501.
13. Display the Employee name and Address who work for ‘Research’ Department
(USING JOINS).
SELECT DISTINCT ENAME, ADDRESS FROM((EMPLOYEE E JOIN WORKS_FOR W ON
E.SSN=W.SSN) JOIN DEPARTMENT D ON W.DNO=D.DNO AND
D.DNAME='RESEARCH');
SELECT IF(1>3,'TRUE','FALSE');
14. Display SSN, Name and HE/SHE for all employees respectively.
15. Display SSN, Name and AGE as Major or Minor for all employees.
16. Create Views for FEMALE employees to check Age>22 and Salary>25000
17. Create Views for MALE employees to check Age>22 and Salary>25000
USE OF TRIGGERS
DELIMITER //
DELIMITER ;