Reputation: 89
I'm new to SQL queries, so I have some problems making them. I'm using SQL Server Management Studio.
My task is to select regional groups of departments where average of salary + commission of employees is less than 2500.
My SQL statement:
select regional_group
from LOCATION
join DEPARTMENT on location.location_id = DEPARTMENT.location_id
join EMPLOYEE on DEPARTMENT.department_id = EMPLOYEE.department_id
where EMPLOYEE.department_id in (select avg(salary + commission)
from employee)
Upvotes: 2
Views: 133
Reputation: 3620
you have to put condition in where clause of inner query
select regional_group
from LOCATION
join DEPARTMENT on location.location_id = DEPARTMENT.location_id
join EMPLOYEE on DEPARTMENT.department_id = EMPLOYEE.department_id
where EMPLOYEE.department_id in (select department_id
from employee
where salary + commission < 2500)
Upvotes: 2
Reputation: 1658
SQL Query
Select L.Reginal_group
From Employee E
Join Department D ON
D.Department_id = E.Department_id
Join Location L ON
D.Location_id = L.Location_id
WHERE avg(E.salary+E.commission) < 2500
Upvotes: 0