关于 TOP n 的语句!
因为select top 200 * from tablename 要比 select * from tablename速度要相对快一些,所以我想只查找前面的一部分记录。
但是,
现在我想查找中间的200条,该怎么写sql命令呢?
有没有 last n 或 mid n之类的命令?
谢谢!!
问题点数:20、回复次数:6Top
1 楼txlicenhe(马可)回复于 2003-12-04 11:50:22 得分 10
没有:
http://expert.csdn.net/Expert/topic/2365/2365596.xml?temp=.5068781
交流--查询第X页,每页Y条记录
邹建
Top
2 楼pengdali()回复于 2003-12-04 11:51:07 得分 5
CREATE PROCEDURE GetProductsPaged
@lastProductID int,
@pageSize int
AS
SET ROWCOUNT @pageSize
SELECT *
FROM Products
WHERE [standard search criteria]
AND ProductID > @lastProductID
ORDER BY [Criteria that leaves ProductID monotonically increasing]
GOTop
3 楼txlicenhe(马可)回复于 2003-12-04 11:51:36 得分 0
eg:
200-400
select top 200 * from (select top 400 * from tablename order by id) order by id desc
Top
4 楼CrazyFor(冬眠的鼹鼠)回复于 2003-12-04 11:53:32 得分 5
查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M-N * from #temptable where iid>=N
OR:
select top M-N * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段Top
5 楼lvltt(未完成)回复于 2003-12-04 12:03:38 得分 0
查询N-M条记录。 select IDENTITY(int,1,1) as iid,* into #temptable from yourtable select top M-N * from #temptable where iid>=N OR: select top M-N * from yourTable where id not in(select top N-1 id from table) ID为表具有唯一值的任何字段Top
6 楼gaoxiaospring(gaoxiaospring)回复于 2003-12-04 13:31:28 得分 0
这样处理后的速度应该不见得就快。Top
相关问题
- SQL语句中select top n的一个小问题!
- Oracle中的Select语句如何实现MSSql中Select Top n的语法功能?
- 请问如何设计一个sql语句提取前n条记录,类似于sql server的top语句功能?(不用存储过程)
- 在oracle中如何检索top n条记录,另外:oracle中的sql 语句在什么地方查呢?
- 请问,sybase数据库中如何使用top N的语句?十万火急,高手们,谢了!
- oracle中怎么选出最前面的几条,类似于sqlserver中的top(n)语句
- 求助,存储过程里面,使用了top n的语句,这个n想设置成变量,如何实现?
- 怎么textBox控件不可以使用 \n,\r等语句??????
- N在SQL语句中的作用问题请教
- 急!急!急!求N-S图的Select Case语句该怎么画?




