DB: SQL SERVER - Find Nth Highest Salary of Employee
来源:互联网 发布:土耳其 新疆 知乎 编辑:程序博客网 时间:2024/05/17 08:05
How to get 1st, 2nd, 3rd, 4th, nth topmost salary from an Employee table
The following solution is for getting 6th highest salary from Employee table ,
SELECT TOP
1 salary
FROM
(
SELECT DISTINCT TOP
6 salary
FROM
employee
ORDER BY
salary
DESC
)
a
ORDER BY
salary
You can change and use it for getting nth highest salary from Employee table as follows
SELECT TOP
1 salary
FROM
(
SELECT DISTINCT TOP
n salary
FROM
employee
ORDER BY
salary
DESC
)
a
ORDER BY
salary
where n > 1 (n is always greater than one)
Same example converted in SQL Server 2005 to work with Database AdventureWorks.
USE
AdventureWorks
;
GO
SELECT TOP
1 Rate
FROM
(
SELECT DISTINCT TOP
4 Rate
FROM
HumanResources.EmployeePayHistory
ORDER BY
Rate
DESC
)
A
ORDER BY
Rate
GO
- DB: SQL SERVER - Find Nth Highest Salary of Employee
- How to find second highest or maximum salary of Employee in SQL - Interview question
- leetcode SQL题目 177. Nth Highest Salary
- LeetCode Nth Highest Salary
- Nth Highest Salary
- Nth Highest Salary
- 177 - Nth Highest Salary
- Nth Highest Salary
- Nth Highest Salary
- MySQL-Nth Highest Salary
- 177. Nth Highest Salary
- Leetcode177. Nth Highest Salary
- 【LeetCode】Second Highest Salary && Nth Highest Salary
- LeetCode | Second Highest Salary & Nth highest salary
- Leetcode177. Nth Highest Salary(SQL语句中使用函数)
- leetcode 177 Nth Highest Salary
- LeetCode_OJ【177】Nth Highest Salary
- leetcode 177. Nth Highest Salary
- 老外整的注册验证码,迄今为止我见过的最N的!
- 残奥会部分未售出门票
- C++ Const 应用总结
- The Source Code Of My World(我的世界之源代码)中的经典语句
- 数据挖掘案例——药物选择决策支持
- DB: SQL SERVER - Find Nth Highest Salary of Employee
- 关于VPM642的调试问题的总结
- x3d技术应用领域
- TFS: 回滚变更集
- 开源的语音识别器:Sphinx-4
- 洋品牌冷对飞鸽传书提速
- x3d浏览器简介
- MS06-040 Remote Code Execution Proof of Concept
- ExtJs2.0学习系列(15)--extjs换肤