假设有一千万条记录,怎么取出最新的一千条?

zzz654321 2003-10-03 05:44:07
假设有一千万条记录,怎么取出最新的一千条?
...全文
38 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
伍子V5 2003-10-03
  • 打赏
  • 举报
回复
1.时间字段
select top 1000 * from tablename order by date desc
2.标识字段
select top 1000 * from tablename order by id desc
westbulls 2003-10-03
  • 打赏
  • 举报
回复
重新写一个,如果有自增字段
select top 100 * from tablename order by id desc
westbulls 2003-10-03
  • 打赏
  • 举报
回复
如果有自增字段:
select * from tablename where id>=ident_curren('tablename')-1000
xylr 2003-10-03
  • 打赏
  • 举报
回复
同意楼上的~
mrh123 2003-10-03
  • 打赏
  • 举报
回复
select top 1000 * from tableName ...
txlicenhe 2003-10-03
  • 打赏
  • 举报
回复
select top 1000 * from 你的表 order by 插入时间 desc
pengdali 2003-10-03
  • 打赏
  • 举报
回复
前提是你记录了插入时间或修改时间。

select top 1000 * from 你的表 order by 插入时间
westbulls 2003-10-03
  • 打赏
  • 举报
回复
有自增字段吗?

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧