我有一张名为"员工"在数据库中如下:
| 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)
任何人都可以帮忙吗?
答案 0 :(得分:1)
试试这个:
select department,sum(salary)
from Employees
group by department
having sum(salary)>1200
<强> FIDDLE DEMO 强>