Hey everyone, I am taking an online Database class and I have had a heck of a time with this current assignment, particularly, question M.
M. Write an SQL statement to show the sum of HoursWorked for each type of OWNER but exclude services of employees who have ExperienceLevel of Junior and exclude any type with less than three members.
Used strikeouts for primary keys.
Referential Integrity Constraints:
OwnerID in PROPERTY must exist in OwnerID in OWNER
PropertyID in SERVICE must exist in PropertyID in PROPERTY
EmployeeID in SERVICE must exist in EmployeeID in EMPLOYEE
So far I have
SELECT OWNER.OwnerType, SUM(HoursWorked) AS TotalHours
FROM SERVICE, OWNER, EMPLOYEE, PROPERTY
WHERE EMPLOYEE.EmployeeID = SERVICE.EmployeeID AND OWNER.OwnerID = PROPERTY.OwnerID AND EMPLOYEE.ExperienceLevel NOT LIKE 'Junior'
GROUP BY OWNER.OwnerType
For some reason it is showing values that are adding up to numbers that are much larger than they should be. Where am I going wrong? Any help would be great.
We're not supposed to answer questions pertaining to homework assignments, because we all had to learn this at some point in our lives and giving you the answer wouldn't be helping you.
I'm not going to give you the answer or write out the SQL Statement that would help you out, however, I will give you a hint.
Make sure you are reviewing what tables each field's information is coming from, and make sure you are declaring that in your SQL statement.
I am a little rusty with my SQL, but I see that error in your SQL so far.
I most certainly wasn't expecting the work to be done for me. Getting a hint is all I was hoping for since I have been looking at this code for so long I have gone blind to what might be wrong. I'll look at it again soon as I get a chance. Thank you for your input.