查找表中的最后50条记录 [英] find the last 50 records in a table
本文介绍了查找表中的最后50条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须找到一个表中的最后50条记录,我不知道有多少条记录.任何人有什么想法都可以,请帮帮我.
提前谢谢您.
i have to find the last 50 records in a table,i dont know how many numbers of records are there.can anybody having any idea then please help me.
thank you in advance.
推荐答案
检查这些
SQL Server选择最后N行 [如何在其中选择最后N行没有排序的表? [
Check these
SQL Server SELECT LAST N Rows[^]
How do I select last N rows in a table without sorting?[^]
尝试一下
select *
from (
SELECT row_number() over(order by BogusRowOrder) as RowNum,
count(*) over() as RowCnt,
*
from (
SELECT 1 as BogusRowOrder,
*
FROM [AdventureWorks].[Production].[Product]
) as a
) as b
where RowNum > RowCnt-50
以下是获取最后50条记录的示例查询:
Here is the sample query to fetch last 50 records:
select *
from Employee where empid not in (
select top (
(select count(*) from Employee) - 5
) empid
from Employee
)
这篇关于查找表中的最后50条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文