如何从表中找到第二高的薪水。 [英] how to find 2nd highest salary from table.

查看:72
本文介绍了如何从表中找到第二高的薪水。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的



i希望从table.table中找到第二高的薪水,在emp表中包含一些重复值。



表格如..



eid名称薪水depatmentid

100 vijay 66000 10

101 sumit 22000 20

102 sohan 25000 30

103 Bhagat 25000 30

104 sunil 22000 40

105 sumit 24000 40

106 sunil 22000 10

107 kumar 26000 50

108史密斯120033 50

110 arun 12033 10

111 gyanesh 122233 50

112 sunita 10033 40

113 kanchan 120033 50



请帮忙解决这个问题......

dear

i want to find second highest salary from table.table contain some duplicate values in emp table.

table like..

eid name salary depatmentid
100 vijay 66000 10
101 sumit 22000 20
102 sohan 25000 30
103 Bhagat 25000 30
104 sunil 22000 40
105 sumit 24000 40
106 sunil 22000 10
107 kumar 26000 50
108 smith 120033 50
110 arun 12033 10
111 gyanesh 122233 50
112 sunita 10033 40
113 kanchan 120033 50

pls help to resolve this problem...

推荐答案

快速搜索Q& A这里会发现你先前已经问过21个问题。



Q& A搜索结果 [< a href =http://www.codeproject.com/search.aspx?q=2nd+highest+salary&x=0&y=0&sbo=qa&usfc=falsetarget =_ blanktitle =新窗口> ^ ]



如果您真的需要社区的帮助,请对您的主题进行简单的Q& A搜索,看看是否问题已被提出。
A quick search on the Q&A here would have found you 21 previous questions already asked here.

Q&A search results[^]

If you really want help from the community, please perform a simple Q&A search on your topic ans see if the question had already been asked.


下面的查询会给你更正确的答案: -



below query will give you more correct answer:-

select * from (
select dense_rank() over (order by sal desc) as num, * from tablename) a
where num=2


SELECT MAX( Salary)
  FROM Emp
 WHERE Salary < ( SELECT MAX(Salary) FROM Emp )


这篇关于如何从表中找到第二高的薪水。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆