答:解1: selecttop 10 * from A where id not in (select top 30 id from A)
解2: select top10 * from A where id > (select max(id) from (select top 30 id from A )as A)
解答3:用ROW_NUMBER实现
求解答3是什么东西????
http://www.cnblogs.com/tangself/archive/2010/09/29/1838234.html
这位园友有讲过,可以看一下,简单说,对于这个题目,用row_number可以写成这样:
--园友文章中的写法,这也是微软官方文档里的写法
WITH B AS (
SELECT *,ROW_NUMBER() OVER(ORDER BY ID ASC) AS ROW_NUM
FROM A WITH(NOLOCK)
)
SELECT *
FROM B WITH(NOLOCK)
WHERE ROW_NUM BETWEEN 31 AND 40
--我一般这么写
SELECT * FROM (
SELECT *,ROW_NUMBER() OVER(ORDER BY ID ASC) AS ROW_NUM
FROM A WITH(NOLOCK)
) B
WHERE ROW_NUM BETWEEN 31 AND 40
楼上不错,其实也就是内置的一个东西吧,oracle可以直接用rownum。。。