--职务平均工资 select 部门,职务,avg(工资) as 平均工资 from a group by 部门,职务
部门、职务、姓名、工资将每部门每个职务只取一人的工资 做代表,做出每个职务的人的平均收入。--------------- select *,identity(int,1,1)TID into #temp from 表select A.部门,avg(A.工资) 平均工资 from #temp A inner join (select min(TID) TID,部门 from #temp group by 部门) B on A.TID=B.TID group by A.部门 drop table #temp
select 部门,职务,avg(工资) as 平均工资
from a
group by 部门,职务
select *,identity(int,1,1)TID into #temp from 表select A.部门,avg(A.工资) 平均工资
from #temp A
inner join
(select min(TID) TID,部门 from #temp group by 部门) B
on A.TID=B.TID
group by A.部门
drop table #temp