问题描述
我有一张桌子
有一些价值
id     name 工资
--------------------------------------
100 saju 30000
200 shibu 44409
300 mnau 36779
400 vinu 65679
900 sunil 56565
489 prabu 87768
345 anil 76467
213 vibin 75676
132 ramu 34546
----------------------------------------- ----------------------------------------
来自此表我想选择第三高薪
如何写这个查询
I have one table
that having some values
id name salary
--------------------------------------
100 saju 30000
200 shibu 44409
300 mnau 36779
400 vinu 65679
900 sunil 56565
489 prabu 87768
345 anil 76467
213 vibin 75676
132 ramu 34546
---------------------------------------------------------------------------------
from this table i want to select third highest salary
how to write the queries for this
推荐答案
select max(salary) from Employeedetails
where salary not in (select top 2 salary from Employeedetails order by salary desc )
WITH CTE
AS
(
SELECT ROW_NUMBER() OVER (ORDER BY RATE DESC)[Rank],Rate from HumanResources.EmployeePayHistory
)
SELECT * FROM CTE
WHERE [Rank]=3
select MIN(salary) from Table_1 where salary in (select distinct Top 3 (salary) from Table_1 order by salary desc)
谢谢
thanks
这篇关于从sql表中选择第三个最高值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!