select B.dept_name,
[平均工资]=avg(A.salary)
from employee A
join deptment B on A.dept_id=B.dept_id
group by B.dept_name
having avg(A.salary)>5000
[平均工资]=avg(A.salary)
from employee A
join deptment B on A.dept_id=B.dept_id
group by B.dept_name
having avg(A.salary)>5000
解决方案 »
- SQL Server 2005有没有自动比对的函数
- 急!!报“数据库服务没有打开,请先打开sql server2000服务”错,为什么??
- SQLServer启动一段时间后操作奇慢无比,怎么办啊?
- 问一个菜鸟的问题 建表时 在表名前加一个# 是什么意思啊
- 请教SQL高手问题
- 要疯了,为什么放了好几百分,一个并不很难的问题却没人回答上来,是我太烂吗?
- 如何把sql server 数据库的image字段保存为图形文件?
- 大家都用过什么比较好的SQLSERVER的编辑器呀???紧急调查!
- ===数据库的导入===
- sqlserver2008修改存储过程提示对象名无效,对象(表)实际已经存在
- 一个不是很难的问题!
- 数据库附加问题,急死人啦!!!!!!!!!!!十万火急啊。
部门名称 = a.dept_name,
平均工资 = avg(b.salary)
from
deptment a
employee b
where
a.dept_id = b.dept_id
group by
a.dept_name
having
avg(b.salary)>5000
create table employee (id int,dept_id int,name varchar(8),salary int)
insert employee select 1,1,'cpp',8000
union all select 2,1,'yp',7000
union all select 3,1,'mg',6000
union all select 4,2,'qwe',1000
union all select 5,2,'wff',3000
union all select 6,2,'yx',2000
union all select 7,2,'sx',8000
union all select 8,3,'jy',2000
union all select 9,3,'xx',4000
create table deptment(id int,dept_id int,dept_name varchar(8))
insert deptment select 1,1,'市场部'
union all select 2,2,'技术部'
union all select 3,3,'财务部' select dept_name,name,avg(salary) avg from employee e join deptment d
on e.dept_id=d.dept_id group by dept_name,name having avg(salary)>5000
on e.dept_id=d.dept_id group by e.dept_id,dept_name having avg(salary)>5000