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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to select a range of records by rownum?

Re: How to select a range of records by rownum?

From: g.r.s. deisz <g.r.s.deisz_at_ptt-telecom.unisource.nl>
Date: 1997/03/25
Message-ID: <5h80up$aql@pwxl01.telecom.ptt.nl>#1/1

Pao Wan wrote:
>
> I want to select records from 40 to 100, and I think the statement
>
> "select rownum, user, email from clients where rownum >= 40 and rownum
 <=100"
>
> will work. But it failed, I tried
>
> "select rownum, user, email from clients where rownum <= 100"
>
> it work. But
>
> "select rownum, user, email from clients where rownum >= 40" failed, can
> anybody help me.

The where clause is evaluated for each record the query may return: The first record is checked, rownum = 1, so it doesn't satisfy the where clause. The second record is checked, again rownum = 1 (because no records are yet returned), and again it doesn't satisfy the where clause. And so on...

You can solve it by using something like: select ..... where rownum <=100
minus
select ..... where rownum <40

Stefan.


Name      :G.R.S. Deisz
Phone     :+31-50-5855954
E mail    :G.R.S.Deisz_at_PTT-Telecom.Unisource.NL
DISCLAIMER:This statement is not an official statement from, nor
           does it represent an official position of, PTT Telecom BV.
Received on Tue Mar 25 1997 - 00:00:00 CST

Original text of this message

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