SQL Solutions - 8 - 13
SQL Solutions - 8 - 13
SQL Solutions - 8 - 13
Note: More than one SQL solution may be provided for the same query.
(a) Retrieve the names of employees in department 5 who work more than 10 hours per week
on the 'ProductX' project.
Result:
LNAME FNAME
Smith John
English Joyce
(b) List the names of employees who have a dependent with the same first name as themselves.
Result (empty):
LNAME FNAME
- ---------
(c) Find the names of employees who are directly supervised by 'Franklin Wong'.
Result:
LNAME FNAME
Smith John
Narayan Ramesh
English Joyce
(d) For each project, list the project name and the total hours per week (by all employees) spent
on that project.
Result:
PNAME SUM(HOURS)
ProductX 52.5
ProductY 37.5
ProductZ 50.0
Computerization 55.0
Reorganization 25.0
Newbenefits 55.0
Result (empty):
LNAME FNAME
- ---------
(f) Retrieve the names of employees who do not work on any project.
Result (empty):
LNAME FNAME
- ---------
(g) For each department, retrieve the department name, and the average salary of employees
working in that department.
Result:
DNAME AVG(SALARY)
Research 33250
Administration 31000
Headquarters 55000
Result:
AVG(SALARY)
31000
(i) Find the names and addresses of employees who work on at least one project located in
Houston but whose department has no location in Houston.
Result:
LNAME FNAME ADDRESS
Wallace Jennifer 291 Berry, Bellaire, TX
(j) List the last names of department managers who have no dependents.
Result:
LNAME FNAME
Borg James