select top 100 * from Table_TestNum where id < 500 order by id desc我是翻页程序,为了取后一百条记录,降序排列取的 top 100
得到了我要的结果,只是显示出来是降序 的数据
我如何 再重新排列 成升序的
得到了我要的结果,只是显示出来是降序 的数据
我如何 再重新排列 成升序的
解决方案 »
- 怎么去掉重复项?
- 我能用sql语句查出sql server2005数据库有哪些存储过程及存储过程的参数等信息吗?
- 各位大虾 帮忙看看啊~~ 急~~在线等 一个关于动态sql 语句的问题
- 求一简单SQL语句,请大侠出手指点
- SQL经典高难度查询
- 请问学习SQLServer的好网站?
- 压缩数据库 DBCC SHRINKDATABASE 问题
- 哪位有空可以帮我看看服务器的状态呈?
- 在全文检索里用order by子句排序后,前面不能加distinct,有解决方法吗?!谢谢
- XP 下安装 SQL Server7 ,然后运行的时候怎么也链接不上本地的服务器
- 单表1千万的数据,分页查询用7-9秒,这样的代码还可以优化吗?
- 使用 @@identity 返回刚才插入的自增列的ID值,总是出现错误。
select * from
(
select top 100 * from Table_TestNum where id < 500 order by id desc
) t order by id
declare @table table(id int)
declare @i int;set @i=1
while(@i<=100)
begin
insert into @table select @i
set @i=@i+1
end--降序取10个,再升序
select id from (
select row_number() over (order by id desc) as rowid, * from @table
) aa where rowid<=10 order by id
/*
id
-----------
91
92
93
94
95
96
97
98
99
100
*/
SELECT * FROM(
select top 100 * from Table_TestNum where id < 500 order by id desc
)A ORDER BY ID
SELECT top 100 * FROM(
select * from Table_TestNum where id < 500 order by id desc
)A ORDER BY ID