写出一条Sql语句: 取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,  注意:ID可能不是连续的。)
解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)
这个top 10 *是什么意思?SQLServer我没学过,这道题要是在ORALCE中要咋么写?

解决方案 »

  1.   

    1,select  * from A where id not in (select  id from A where rownum<31 ) and rownum<11
    2,select  * from A where id>(select max(id) from A where rownum<31 ) and rownum<11
      

  2.   

    top 10 * 是取符合条件的前10行数据记录的意思
      

  3.   

    oracle没有TOP 10这种表达方式!
      

  4.   

      对二楼的写法有些疑问,主要还是oracle的rownum不是固定的,每一次查询是不一样的。
       能不能得出第30至40行的数据?
      

  5.   


    oracle的写法,取出表A中第31到第40记录
    select *
      from (select rownum rn, t.* from (select A.* from A order by id asc) t)
     where rn between 31 and 40
      

  6.   

    oracle里面是序列,可以如下试试看:
    select a.* from (select * from A where order by id asc) a where a.rownum<41 and a.rownum>29