1. select dept,sum(isnull(salary,0)) from table1 group by dept
1.select sum(salary) from table1 group by dept 2.select ename,dept from table1 group by dept having(salary)>avg(salary)
1、输出每个部门的工资总和(只输出工资总和一项,其他的项不要)select sum(salary) as salary from table1 group by dept2、输出每个部门工资高于该部门平均工资的员工姓名(只要姓名一项,其他的项不要)select a.name from table1 a, (select dept,avg(salary) as salary from table1 group by dept) b where a.dept=b.dept and a.salary>b.salary
select sum(salary) as salary from table1 group by dept select ename from table1 group by dept having(salary)>avg(salary)
1. select dept,sum(isnull(salary,0)) as salary from table1 group by dept2. select ename from table1 a, ( select dept,avg(isnull(salary,0)) as salary from table1 group by dept) b where a.dept = b.dept and a.salary > b.salary
2. select ename from table1 where salary>(select avg(salary) from table1 a where a.dept=table1.dept group by dept)
select dept,sum(isnull(salary,0)) from table1 group by dept
2.select ename,dept from table1 group by dept having(salary)>avg(salary)
a.name
from
table1 a,
(select dept,avg(salary) as salary from table1 group by dept) b
where
a.dept=b.dept and a.salary>b.salary
select ename from table1 group by dept having(salary)>avg(salary)
select dept,sum(isnull(salary,0)) as salary from table1 group by dept2.
select ename from table1 a,
(
select dept,avg(isnull(salary,0)) as salary from table1 group by dept) b
where a.dept = b.dept and a.salary > b.salary
select ename
from table1
where salary>(select avg(salary) from table1 a where a.dept=table1.dept group by dept)