从SQL Server表中选择Nth Min元素

Ros*_*nir 2 sql t-sql sql-server

我需要你的帮助 :_)

我有一个Invoice带有列的表Id, Name, Address, Total,我需要能够拉出第N个Total元素.

我试过这段代码:

select 
    Min(total) 
from
    (select top(5) Total  
     from Invoice 
     order by Total desc) as Total
Run Code Online (Sandbox Code Playgroud)

它工作,但它只显示一列没有Id,名称和地址..((

我该如何解决它并展示一切?

Gor*_*off 5

实际上,你可以使用offset/ 来做到这一点fetch:

select i.*
from Invoice
order by Total desc
offset 4 rows fetch first 1 row only;
Run Code Online (Sandbox Code Playgroud)