取各部门第三高工资

来源:互联网 发布:10岁考上大专 知乎 编辑:程序博客网 时间:2024/04/29 00:20
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
 
原创粉丝点击