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

Home -> Community -> Mailing Lists -> Oracle-L -> ROWNUM question ???

ROWNUM question ???

From: Janet Linsy <janetlinsy_at_yahoo.com>
Date: Fri, 08 Feb 2002 17:36:40 -0800
Message-ID: <F001.0040B040.20020208172913@fatcity.com>

Hi,

I have a table like this:

SQL> select * from test;

        ID PRICE
---------- ----------

         1          1
         1          3
         1          4
         1          5
         1          6

I need to get the second largest price and I was using the ROWNUM.

For the following statement, the result makes sense: SQL> select * from test where rownum < (select count(*) -1 from test);

        ID PRICE
---------- ----------

         1          1
         2          3
         3          4

But the rest twos didn't return anything:

SQL> select * from test where rownum=(select count(*)
-1 from test); -- supposed to return 5 ???

no rows selected

SQL> select * from test where rownum > (select count(*) -1 from test); -- supposed to return 6 ???

no rows selected

I vaguely remember that ROWNUM only works in < case, why is that? Thank you!



Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Janet Linsy
  INET: janetlinsy_at_yahoo.com
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (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). Received on Fri Feb 08 2002 - 19:36:40 CST

Original text of this message

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