declare @t table(部门 char(10),姓名 char(20),工资 int)
insert @t select 'aa','dddd',800
union all select 'aa','aaaa',1000
union all select 'aa','bbbb',900
union all select 'bb','cccc',2000
union all select 'bb','eeee',5000
union all select 'bb','ffff',1800
union all select 'bb','gggg',1300
union all select 'aa','hhhh',600
select *from (SELECT *,Place=(SELECT COUNT(DISTINCT 工资) FROM @t WHERE 工资>=a.工资 and 部门=a.部门)
FROM @t a ) b where place=3
insert @t select 'aa','dddd',800
union all select 'aa','aaaa',1000
union all select 'aa','bbbb',900
union all select 'bb','cccc',2000
union all select 'bb','eeee',5000
union all select 'bb','ffff',1800
union all select 'bb','gggg',1300
union all select 'aa','hhhh',600
select *from (SELECT *,Place=(SELECT COUNT(DISTINCT 工资) FROM @t WHERE 工资>=a.工资 and 部门=a.部门)
FROM @t a ) b where place=3