Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> ROWNUM question ???
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!
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Liststo: 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
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message