记下SQL,以显示员工(工资大于5000)的平均工资低于8000的部门。
这就是我写的。我不确定这是否正确。
select departments.department_name, employees.avg(salary) as avgsalary from departments
inner join employees
on departments.department_id = employees.department_id
where avgsalary > 5000 and avgsalary < 8000;
答案 0 :(得分:1)
select departments.department_name
, avg(employees.salary) as avgsalary
from departments inner join employees
on departments.department_id = employees.department_id
group by departments.department_name
having avg(employees.salary) > 5000 and avg(employees.salary) < 8000;