任何人都可以帮助我如何获得第n个最高薪水而不使用top [英] can anybody help me how to get nth highest salary without using top
本文介绍了任何人都可以帮助我如何获得第n个最高薪水而不使用top的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮助我如何获得第n个最高薪水而不使用top
can anybody help me how to get nth highest salary without using top
推荐答案
哪个数据库系统?
如果使用SQL Server,请使用FETCH查看ROW_NUMBER()或ORDER BY {FIRST | NEXT} {integer_constant | fetch_row_count_expression} {ROW | ROWS}只有
https://msdn.microsoft.com/en-us /library/ms188385.aspx [ ^ ]
Which database system?
If SQL Server, look into ROW_NUMBER() or ORDER BY with FETCH { FIRST | NEXT } { integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY
https://msdn.microsoft.com/en-us/library/ms188385.aspx[^]
不使用循环你可以通过多种方式获得它,但它取决于sql Server版本
Row_Number 2008+ [ ^ ]
< a href =https://technet.microsoft.com/en-us/library/gg699618(v=sql.110).aspx> OFFSET FETCH 2012+ [ ^ ]
< a href =https://msdn.microsoft.com/en-IN/library/ms175972.aspx> Common Table Expression 2008+ [ ^ ]
Sub_Query
等
尝试:
Without using the Loop you can get it in many ways, but it depend upon the sql Server version
Row_Number 2008+[^]
OFFSET FETCH 2012+[^]
Common Table Expression 2008+[^]
Sub_Query
etc.
Try:
;with cte as
{
select top 5 * from Table_Name order by Column_Name Asc
)
select top 1 * from cte order by Column_Name Desc
这篇关于任何人都可以帮助我如何获得第n个最高薪水而不使用top的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文