select * from (select * from tbname desc) where rownum<11;

解决方案 »

  1.   

    select * from tablename where rownum<11 order by filed1 desc ;
      

  2.   

    "select * from tablename where rownum<11 order by filed1 desc ;"这个语句是把取出来的记录再排序吧。
      

  3.   

    关键是我没有一个字段是排序字段。还能解决吗?
    ------------------------------------------
    能. :)select * from (select * from tabName order by rownum desc) where rownum<=3;
    rownum 表示行号,是 Oracle 数据字典里的关键字.另:
    如果表里的数据是 insert 进去的话,Oracle 表里本身就不按顺序.
    总要有一个字段来做排序比较好.
      

  4.   

    table1.last
    i:=1;
    while not table1.bof and i<=10 do
    begin
      doSomething;
      inc(i);
      table1.prior;
    end;
      

  5.   

    table1.last;
    i:=1;
    while (not table1.bof) and (i<=10) do
    begin
      doSomething;
      inc(i);
      table1.prior;
    end;
      

  6.   

    select * from (select * from tabName order by rownum desc) where rownum<=3;
    這句sql語句會首先找出所有的記錄然后再去選出最后3筆記錄﹐
    所以還是進行了全表掃描﹐
      

  7.   

    table1.last;
    i:=1;
    while (not table1.bof) and (i<=10) do
    begin
      doSomething;
      inc(i);
      table1.prior;
    end;
    呵呵﹐看布懂﹐可以解釋一下嗎﹖
    謝謝
    另外﹐這是sql語句嗎﹖
    table.prior,這樣的語句是在哪里用的阿﹖
      

  8.   

    select * from tablename where rownum<11 order by filed1 desc ;这样是不行的,这个语句是把取出来的记录再排序;
    select * from (select * from tabName order by rownum desc) where rownum<=*;
    也不是最好的办法,正如上面的朋友说的那样,这样在提取记录之前还是对整个表中的记录做了操作,效率不是很高,违背了本来的意愿。
      

  9.   

    select * from (select *,rownum from you_table where rownum<m+m+1) 
    where rownum>m-1 and rownum<m+m+1 
    http://www.oracle.com.cn/cgi-bin/topic_show.cgi?id=4266&h=1&bpg=4&age=0
    http://expert.csdn.net/Expert/topic/2566/2566792.xml?temp=1.437014E-02