Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: selecting the last 10 rows...

Re: selecting the last 10 rows...

From: victor <victor_at_PERCOMBANK.KIEV.UA>
Date: 30 Nov 1998 09:48:28 GMT
Message-ID: <01be1c46$9e289220$6b14abcc@victor>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US