这就是个分页取值的原型...
31条到40条就是10条数据
select top 10 * from 表名 where id not in (select id from 表名 )
这样就可以过滤掉前面30条了,其中语句中的'id'值是用来过滤的,无论的你的ID是否连续,只要出现在子查询中的ID,主查询都会把他过滤掉,这样就可以实现31-40的查询了
望采纳
SQL语句为:
select * from A where ID >=31 and ID <= 40
ORACLE语句为:
select * from A where RowNum>=31 and RowNum<=40
ORACLE和SQL都能使用的是
select top 10 * from (select top 40 * from A order by ID) order by ID desc
或者是
select top 10 * from A where ID not in (select ID from top 30 from A)
sql:
select top 10 * from (select top 40 * from A order by A.ID)T
order by T.ID desc
orcal:
SELECT * FROM (SELECT ROW_.*, ROWNUM ROWNUM_ FROM (
SELECT * FROM A
)ROW_ WHERE ROWNUM <=40) WHERE ROWNUM_ > 31
望采纳
不好意思之前算错数,下面一句SQL代码返回第31到第40共10条记录,按自动ID升序排序:
SELECT T2.* FROM (SELECT TOP 10 T1.* FROM (SELECT TOP 40 * FROM TABLE1 ORDER BY ID)T1 ORDER BY T1.ID DESC) T2 ORDER BY T2.ID
SELECT TOP 10 * FROM 表名 WHERE ID NOT IN(SELECT ID FROM TOP 30 FROM 表名)
肯定可以用。。