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: Q: returning rows between two positions in a large query

Re: Q: returning rows between two positions in a large query

From: Mark G <mgumbs_at_nospam.hotmail.com>
Date: Tue, 22 Jun 1999 16:02:03 +0100
Message-ID: <376fa324.0@145.227.194.253>


The suggested solutions are fine for simple queries but once you start doing sorts on the tables, as the original thread suggested, the rownum method may return unexpected results. Using rownum will return the stated amount of records but ONLY in the order which is stored in a table.

e.g You couldn't do query to search on the top 2000 items, sort by occurence and then find all items between position 100 and 200.

Combining all this, why don't you do your initial query, save it to a temp table in the order you want and then use the rownum method stated below based on the sorted temp table?

Mark

shiling_at_math.wayne.edu wrote in message <7ko40t$959$1_at_nnrp1.deja.com>...
>The following example selects records between #3-#4.
>
>SQL> select * from t
> 2 ;
>
>TDATE
>---------
>09-JAN-99
>09-JAN-98
>09-JAN-97
>09-JAN-96
>09-JAN-95
>09-JAN-94
>
>6 rows selected.
>
>SQL> select * from t where rownum<=4
> 2 minus
> 3 select * from t where rownum<=2;
>
>TDATE
>---------
>09-JAN-96
>09-JAN-97
>
>SQL>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Tue Jun 22 1999 - 10:02:03 CDT

Original text of this message

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