44.9k views
3 votes
Write an SQL statement to show the sum of HoursWorked for each Type of OWNER but exclude services of employees who have an ExperienceLevel of Junior and exclude any Type with less than three members.

User Shiroko
by
3.8k points

2 Answers

6 votes

Final answer:

To show the sum of HoursWorked for each Type of OWNER but exclude services of employees who have an ExperienceLevel of Junior and exclude any Type with less than three members, you can use the provided SQL statement.

Step-by-step explanation:

To show the sum of HoursWorked for each Type of OWNER but exclude services of employees who have an ExperienceLevel of Junior and exclude any Type with less than three members, you can use the following SQL statement:

SELECT Type, SUM(HoursWorked) AS TotalHours
FROM table_name
WHERE ExperienceLevel <> 'Junior'
GROUP BY Type
HAVING COUNT(Type) >= 3;

This statement selects the Type and calculates the sum of HoursWorked for each Type, excluding records with ExperienceLevel 'Junior' and Types with less than three members.

User Keidi
by
4.7k points
5 votes

Answer:

select sum(HoursWorked)

from OWNER

where ExperienceLevel <> 'Junior'

group by ExperienceLevel

having count(*) >= 3

Step-by-step explanation:

First use the sum function on HoursWorked column of OWNER table. Then put the required condition of not including employees with experience level of Junior. And then use group by function to bulk the results by experience level and group only results with equal to or more than 3 records.

User Clayton Gulick
by
4.1k points