我在数据库中有一个名为“Employees”的表,如下所示:
| name | department | salary |
------ ----------- ------
Divya HR 500
Sumanth HR 600
Div FIN 600
Sum FIN 700
GD ENG 700
MVS ENG 800
+---------+------------+--------+
现在我想选择员工工资超过1200的部门。
结果:
FIN(600+700) and ENG(700+800)
有人能帮忙吗?
最佳答案
试试这个:
select department,sum(salary)
from Employees
group by department
having sum(salary)>1200
FIDDLE DEMO