本文介绍了如何找到第3个最高薪水..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当表包含重复数据时如何找到第3个最高工资。
how to find 3rd maximum salary when table contains duuplicate data.
推荐答案
SELECT
TOP 1 mark
FROM
(SELECT DISTINCT TOP 3 mark FROM mark ORDER BY mark DESC) a ORDER BY mark
select * from (
select dense_rank() over (order by sal desc) as num, * from tablename) a
where num=3
Select top 3 * from Table order by salary
在第二个查询中换行
Wrap that in a second query
Select top 1 *
From (Select top 3 * from Table order by salary)
order by salary desc
使用Row_Number有一个更复杂的解决方案,但上面的工作将完成。
There is a more complex solution using Row_Number but the above will do the job.
这篇关于如何找到第3个最高薪水..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!