Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: selecting the last 10 rows...
John Strange <jstrange_at_imtn.dsccc.com> wrote in article
<73sg98$b4v$1_at_relay1.dsccc.com>...
> Ok, is this any better
>
> select whatever
> from where_ever
> where rownum > (select max (rownum) - 10
> from where_ever
> )
> order by ordered_column descending
>
>
THIS IS WRONG TO
becose at first rownum=0 and stay=1 only when all where clause is true
its never will be in this query
try to use hint /*+ INDEX_DESC(tbl_name,idx_name)*/ may be helpfull
select /*+ INDEX_DESC(where_ever,pk_where_ever)*/
whatever
from where_ever
where rownum <11
Received on Mon Nov 30 1998 - 03:48:28 CST