我是SQL查询的新手,所以在进行查询时遇到了一些问题。我正在使用SQL Server Management Studio。
我的任务是选择平均工资+佣金低于2500的地区部门部门。
我的SQL语句:
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)
答案 0 :(得分:2)
您必须在内部查询的where子句中放置条件
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)
答案 1 :(得分:0)
SQL查询
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