My query below is probably flawed...  I just remembered you would have to
alias rownum...

select inner_row as rownum, gender
from (select rownum as inner_row, gender
from emp2 where rownum <= 600)
where rownum >= 500;

Regards,
      Mark.

Ryan did a good job of explaining the use of rownum - better than my
attempt.



                                                                                       
                                               
                      Mark Richard                                                     
                                               
                                               To:      [EMAIL PROTECTED]              
                                            
                      09/07/2003 11:37         cc:                                     
                                               
                                               Subject: Re: something appears to be 
funny with ROWNUM(Document link: Mark Richard)    
                                                                                       
                                               



ROWNUM has to start from 1 - If you never select a row then rownum can't
increase.  You have to assign rownums and then filter them out later,
usually using a subquery.

The solution to your specific query below would be something like:

select rownum, gender
from (select rownum, gender
      from emp2
      where rownum <= 600
)
where rownum >= 500;

The emails I sent earlier for your other problem are based around the fact
that rownum will restart from 1 during each iteration.  You possibly don't
understand rownum properly - it is a unique number assigned to a specific
result set, not the rows existing in the underlying table.  It must start
from 1 each time and therefore where clauses can only test some conditions
like "rownum = 1" (get a single row), "rownum <= x" (get up to x rows).




                                                                                       
                                               
                      MaryAnn Atkinson                                                 
                                               
                      <[EMAIL PROTECTED]        To:       Multiple recipients of list 
ORACLE-L <[EMAIL PROTECTED]>                  
                      .com>                    cc:                                     
                                               
                      Sent by:                 Subject:  something appears to be funny 
with ROWNUM                                    
                      [EMAIL PROTECTED]                                                
                                               
                      .com                                                             
                                               
                                                                                       
                                               
                                                                                       
                                               
                      09/07/2003 12:14                                                 
                                               
                      Please respond to                                                
                                               
                      ORACLE-L                                                         
                                               
                                                                                       
                                               
                                                                                       
                                               




1. this first query gave me 600 lines of output.

SELECT Rownum, Gender
FROM   EMP2
WHERE  ROWNUM <= 600;

------------

2. this one right here told me no rows selected...

SELECT Rownum, Gender
FROM   EMP2
WHERE  ROWNUM BETWEEN 500 and 600;

I dont get it... something is funny with ROWNUM...


Any ideas?
thx
maa

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: MaryAnn Atkinson
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).





<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   Privileged/Confidential information may be contained in this message.
          If you are not the addressee indicated in this message
       (or responsible for delivery of the message to such person),
            you may not copy or deliver this message to anyone.
In such case, you should destroy this message and kindly notify the sender
           by reply e-mail or by telephone on (61 3) 9612-6999.
   Please advise immediately if you or your employer does not consent to
                Internet e-mail for messages of this kind.
        Opinions, conclusions and other information in this message
              that do not relate to the official business of
                         Transurban City Link Ltd
         shall be understood as neither given nor endorsed by it.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>




<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Privileged/Confidential information may be contained in this message.
If you are not the addressee indicated in this message (or responsible for delivery of 
the message to such person), you may not copy or deliver this message to anyone.
In such a case, you should destroy this message and kindly notify the sender by reply 
e-mail or by telephone on (03) 9612-6999 or (61) 3 9612-6999.
Please advise immediately if you or your employer does not consent to Internet e-mail 
for messages of this kind.
Opinions, conclusions and other information in this message that do not relate to the 
official business of Transurban Infrastructure Developments Limited and CityLink 
Melbourne Limited shall be understood as neither given nor endorsed by them.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Mark Richard
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to