写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增长的ID作为主键,注意:ID可能不是连续的。
sql server:
解1: select top 10 * from A where id not in (select top 30 id from A);
解2: select top 10 * from A where id > (select max(id) from (select top 30 id from A )as A);
oracle:
以t_test为例:
select rownum num,tid from (select rownum num,tid from t_test) where num>=30 and num<=41;
ps:如果不理解rownum用法的话可以看上一篇的博文。
转载于:https://blog.51cto.com/bckong/1333877