Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the tables below: Provide the SQL statements to: 1) Retrieve the names of

ID: 3741131 • Letter: U

Question

Using the tables below:

Provide the SQL statements to:

1) Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project.

2) List name of each employee who has a dependent with the same sex as themselves.

3) Find the name of each employee who is directly supervised by ‘Franklin Wong.’

4) For each project, list the project name and the total hours per week (by all employees) spent on that project.

5) If an employee works on all the projects, retrieve the name of the employee.

6) If an employee does not work on any project, retrieve the name of the employee.

7) For each department, retrieve the department name and the average salary of all employees working in that department.

8) Retrieve the average salary of all female employees.

9) Find the name of each employee who works on at least one project located in Houston but whose department has no location in Houston.

10) List the name of each department manager who has no dependents.

11) List the name of each department manager who has no dependents. (do not use SQL operators and constructors such as NOT IN, NOT EXISTS, MINUS, COUNT)

12) For each employee, show how many employee(s) each supervises.

13) Retrieve the name of employee whose salary is greater than the average salary of all the employees in department 5.

14) Retrieve the name of employee whose salary is greater than the average salary of his or her corresponding department.

15) List the social security number of each employee who does not work on any one of projects with project number 1, 2, or 3.

16) List the social security number of each employee who works on the projects other than the projects with project number 1, 2, or 3.

17) If an employee works on both project 1 and 2, then list the employee’s social security number and name.

18) Retrieve the social security numbers of all direct and indirect supervisees James Borg has.

19) List the name of each department, and the total number of employees with salaries greater than $30,000, and only the department with more than one employee.

TABLE Employee

NAME                   SSN               BDATE             SEX            SALARY          SUPERSSN       DNO

-------------------           ---------            ---------               ---              ----------              ---------              --------

John B Smith         123456789       09-JAN-55        M               30000              333445555          5

Franklin T Wong      333445555      08-DEC-45       M               40000              888665555          5

Alicia J Zelaya        999887777       19-JUL-85        F                25000              987654321         4

Jennifer S Wallace    987654321     20-JUN-31       F                43000              888665555         4

Ramesh K Narayan    666884444    15-SEP-52       M              38000              333445555         5

Joyce A English         453453453    31-JUL-62        F               25000              333445555         5

Ahmad V Jabbar        987987987    29-MAR-59       M              25000              987654321         4

James E Borg            888665555 10-NOV-27          M              55000                                       1

TABLE Department;

DNAME                        DNUMBER         MGRSSN              MGRSTARTD

---------------                       --------                   ---------                     ---------

Research                             5                              333445555           22-MAY-78

Administration                    4                              987654321           01-JAN-85

Headquarters                      1                              888665555           19-JUN-71

TABLE Project

PNAME                      PNUMBER          PLOCATION                       DNUM

---------------                       --------                 ---------------                       --------

ProductX                             1                         Bellaire                          5

ProductY                             2                         Sugarland                      5

ProductZ                              3                        Houston                         5

Computerization                   10                       Stafford                          4

Reorganization                     20                       Houston                          1

Newbenefits                        30                        Stafford                            4

TABLE Deptlocation

DNUMBER         DLOCATION

--------                   ---------------

1                              Houston

4                              Stafford

5                              Bellaire

5                              Houston

5                              Sugarland

TABLE workson

ESSN                 PNO                     HOURS

---------                --------                    ----------

123456789           1                              32.5

123456789           2                              7.5

666884444           3                              40

453453453           1                              20

453453453           2                              20

333445555           2                              10

333445555           3                              10

333445555           10                           10

333445555           20                           10

999887777           30                           30

999887777           10                           10

ESSN                      PNO            HOURS

---------                      --------            ----------

987987987          10                        35

987987987          30                         5

987654321          30                        20

987654321          20                        15

888665555          20

Explanation / Answer

As per Chegg guidelines, if a question of the user contains more than one question then the expert need to answer the first four questions. As I need to follow the guidelines I am answering the first four questions. Hope you read the guidelines and understand. :)

1. SELECT NAME
FROM EMPLOYEE, WORKS_ON, PROJECT
WHERE DNO=5 AND SSN=ESSN AND PNO=PNUMBER
AND PNAME='ProductX' AND HOURS>10

2. SELECT NAME
FROM EMPLOYEE, DEPENDENT
WHERE SSN=ESSN AND SEX = dependent_sex;

3.  SELECT E.NAME
FROM EMPLOYEE E, EMPLOYEE S
WHERE S.NAME='Franklin T Wong'
E.SUPERSSN = S.SSN

4. SELECT PNAME, SUM (HOURS) FROM PROJECT, WORKS_ON
WHERE PNUMBER=PNO GROUP BY PNAME

**Comment for any further queries.