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

OWNER ( OwnerID, OwnerName, OwnerEmail, OwnerType ) PROPERTY ( PropertyID, Prope

ID: 3680695 • Letter: O

Question

OWNER ( OwnerID, OwnerName, OwnerEmail, OwnerType )
PROPERTY ( PropertyID, PropertyName, Street, City, State, Zip,OwnerID )
EMPLOYEE ( EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel )
SERVICE ( PropertyID, EmployeeID, ServiceDate, HoursWorked )

Write an SQL statement to show the sum of hours worked for each type of OWNER but exclude services of employees who have ExperienceLevel of Junior and exclude any type with less than three members. The result should look like the following:

OwnerType SumOfHoursWorked Individual 15

Explanation / Answer

SELECT OwnerType, SUM(HoursWorked) AS SumOfHoursWorked
FROM EMPLOYEE, SERVICE, OWNER
WHERE EMPLOYEE.EmployeeID = SERVICE.EmployeeID
AND EMPLOYEE.ExperienceLevel <> 'Junior'
AND EMPLOYEE.ExperienceLevel IN(SELECT ExperienceLevel FROM Employee HAVING COUNT(DISTINCT(ExperienceLevel))> 2)