1 / 14

Exercise 3 SQL

Exercise 3 SQL. 6 Relations of Company. Exercises. (a) Retrieve the names of employees in department 5 who work more than 10 hours per week on the 'ProductX' project. (b) List the names of employees who have a dependent with the same first name as themselves.

peony
Télécharger la présentation

Exercise 3 SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exercise 3SQL Database System-dww

  2. 6 Relations of Company Database System-dww

  3. Exercises • (a) Retrieve the names of employees in department 5 who work more than 10 hours per week on the 'ProductX' project. • (b) List the names of employees who have a dependent with the same first name as themselves. • (c) Find the names of employees that are directly supervised by 'Franklin Wong'. • (d) For each project, list the project name and the total hours per week (by all employees) spent on that project • (e) Retrieve the names of employees who work on every project. Database System-dww

  4. Exercises • (f) Retrieve the names of employees who do not work on any project. • (g) For each department, retrieve the department name, and the average salary of employees working in that department. • (h) Retrieve the average salary of all female employees. • (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. • (j)List the last names of department managers who have no dependents. Database System-dww

  5. select FNAME, LNAME from EMPLOYEE, WORKS_ON, PROJECT where DNO=5 and SSN=ESSN and PNO=PNUMBER and HOURS > 10 and PNAME=ProductX select FNAME, LNAME from EMPLOYEE where DNO=5 and SSN in ( select ESSN from WORKS_ON where HOURS > 10 and PNO in( select PNUMBER from PROJECT where PNAME = ProductX)) Retrieve the names of employees in department 5 who work more than 10 hours per week on the 'ProductX' project Database System-dww

  6. select FNAME, LNAME from EMPLOYEE, DEPENDENT where SSN=ESSN and FNAME=DEPENDENT_NAME select FNAME, LNAME from EMPLOYEE where exist ( select * from DEPENDENT where ESSN=SSN and FNAME and DEPENDENT_NAME=FNAME) List the names of employees who have a dependent with the same first name as themselves. Database System-dww

  7. select FNAME, LNAME from E.EMPLOYEE, S.EMPLOYEE where S.SSN = E.SUPERSSN and S.FNAME=Franklin and S.LNAME=Wong select FNAME, LNAME from EMPLOYEE where SUPERSSN in ( select SSN from EMPLOYEE where FNAME=Franklin and LNAME=Wong) Find the names of employees that are directly supervised by 'Franklin Wong'. Database System-dww

  8. select PNAME, SUM (HOURS) from PROJECT, WORKS_ON where PNUMBER=PNO group by PNAME For each project, list the project name and the total hours per week (by all employees) spent on that project Database System-dww

  9. select FNAME, LNAME from EMPLOYEE where not exist ( select PNUMBER from PROJECT where not exist ( select * from WORKS_ON where PNO=PNUMBER and ESSN=SSN)) Retrieve the names of employees who work on every project Database System-dww

  10. select FNAME, LNAME from EMPLOYEE where not exist ( select * from WORKS_ON where ESSN=SSN) Retrieve the names of employees who do not work on any project Database System-dww

  11. select DNAME, AVG (SALARY) from DEPARTMENT, EMPLOYEE where DNUMBER=DNO group by DNAME For each department, retrieve the department name, and the average salary of employees working in that department. Database System-dww

  12. select AVG (SALARY) from EMPLOYEE where SEX='F' Retrieve the average salary of all female employees Database System-dww

  13. select FNAME, LNAME, ADDRESS from EMPLOYEE where exist ( select * from WORKS_ON, PROJECT where PLOCATION = Houston and PNO=PNUMBER and ESSN=SSN and not exist ( select * from DEP_LOCATIONS where DNO=DNUMBER and DLOCATION= Houston)) 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 Database System-dww

  14. select LNAME from EMPLOYEE where exist ( select * from DEPARTMENT where SSN=MGRSSN and not exist ( select * from DEPENDENT where SSN=ESSN )) List the last names of department managers who have no dependents Database System-dww

More Related