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: [EMAIL PROTECTED]

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: [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