oracle:select * from table1 where rownum <= n minus select * from table1 where rownum <= m; sql server:select top n * from (select top m * from tablename order by columnname) a order by columnname desc
-51 - 100 select top 49 * from (select top 100 * from dbo.Table_1 order by t1 ) a order by t1 desc
从n行到m行select top m * //先取出前m行 from tablename where id not in( //过滤掉前n行 select top n id from tablename )对...这个
select * from (select *,row_number.ever(order by ) as rownumber from xxx) where rownumber between 10 and 20
从第M行开始 到第N行 select top n * where not exist(select top * m from table) 大概是这样吧 先筛前N行 然后再把前M行去掉 N>M
select top(m-n)* from tablename where id not in (select top n id from tablename)
从n行到m行: select top(m-n)* from tablename where id not in (select top n id from tablename) 比如第10行到15 tablename表中id假如依次为:1 3 4 5 6 8 9 10 11 12 13 14 16 19 28 那么他查出来的结果就是id为13 14 16 19 28的那几行数据。
常用的是rownumber();效率适中!!如果追求效率就用 select top n * from (select top m * from tablename order by columnname) a order by columnname desc
要看是什么数据啊 sql server 2005 直接用 row_number()了如果是 access sql server2000之类的,那就要自己计算行号,生成派生表,再查询
select top(20) * from xfq_SurveyQuestionAnswer where id not in(select top(10) id from xfq_SurveyQuestionAnswer)
--查询输入第m条-第n条出租房屋信息 select top (m-n) * from hos_house where HMID not in(select top m HMID from hos_house) select top (m-n) * from hos_house where HMID between n and m
from tablename
where id not in( //过滤掉前n行
select top n id
from tablename
)
minus
select * from table1 where rownum <= m;
sql server:select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc
select top 49 * from
(select top 100 * from
dbo.Table_1 order by t1 ) a
order by t1 desc
from tablename
where id not in( //过滤掉前n行
select top n id
from tablename
)对...这个
select top n * where not exist(select top * m from table)
大概是这样吧 先筛前N行 然后再把前M行去掉 N>M
select top(m-n)* from tablename where id not in (select top n id from tablename)
比如第10行到15
tablename表中id假如依次为:1 3 4 5 6 8 9 10 11 12 13 14 16 19 28
那么他查出来的结果就是id为13 14 16 19 28的那几行数据。
常用的是rownumber();效率适中!!如果追求效率就用
select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc
sql server 2005 直接用 row_number()了如果是 access sql server2000之类的,那就要自己计算行号,生成派生表,再查询
select top(20) * from xfq_SurveyQuestionAnswer where id not in(select top(10) id from xfq_SurveyQuestionAnswer)
select top (m-n) * from hos_house where HMID not in(select top m HMID from hos_house)
select top (m-n) * from hos_house where HMID between n and m