如何在不使用max()或top()的情况下找到第二高的薪水 [英] how to find 2nd higest salary without using max() or top()
本文介绍了如何在不使用max()或top()的情况下找到第二高的薪水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能告诉我如何在不使用max()或top()的情况下找到第二高的薪水吗?
can you tell me how to find 2nd highest salary without using max() or top()?
推荐答案
1. WITH Results as
(SELECT Row_Number() over (ORDER BY Salary DESC) as RN,* FROM tbPay)
SELECT * FROM Results WHERE RN=2
2. select PayAmount from (
select *,ROW_NUMBER()over(order by PayAmount desc)High from tbpay
)a where High=2
这篇关于如何在不使用max()或top()的情况下找到第二高的薪水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文