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: Select ranges of rows

Re: Select ranges of rows

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 24 Feb 2002 15:24:09 -0800
Message-ID: <a5bsmp01u63@drn.newsguy.com>


In article <a5bs3b$67a5g$1_at_ID-115330.news.dfncis.de>, Kalamaro says...
>
>Hi. I have a problem selecting a range of rows. What i want is to get the
>rows from X to Y in a specific order. I've found that:
>
> SELECT *
> FROM tableX
> WHERE rowid in (
> SELECT rowid FROM tableX
> WHERE rownum <= 7
> MINUS
> SELECT rowid FROM tableX
> WHERE rownum < 5);
>
>It works, but it's hard to apply it to my query. Is there another way to do
>the same (with views or something else)?
>
>thanks

select *
  from ( select a.*, rownum rnum

           from ( YOUR_QUERY_GOES_HERE, including the order by ) a
          where rownum <= MAX_ROWS )

 where rnum >= MIN_ROWS
/
--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Sun Feb 24 2002 - 17:24:09 CST

Original text of this message

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