rownum will not work for "rownum = anything_but_1".
this is because rownum is assigend after the cursor is fetched.
oracle fetches the first row and assigns a rownum of 1, checks where rownum
= 5 condition, finds that it is not satisfied and discards the row.
it fetches another row, and since the prev row is discarded this new row
will have a rownum of 1 and so it is also discarded...
thus only if you give rownum = 1 or rownum < x it will work.
the following will not work
rownum = x where x >1
rownum > x where x > 0
babu
----- Original Message -----
To: "Multiple recipients of list ORACLE-L" <[EMAIL PROTECTED]>
Sent: Wednesday, July 11, 2001 4:44 PM
> List,
>
> Following are two SQL statements. The first SQL statement works OK (where
> ROWNUM < 5 is used). The second SQL statement does not return any rows
> (where ROWNUM = 5 is used). This table contains 200 records.
>
> First SQL statement
> -------------------
> SELECT * FROM
> (SELECT PROCESSED_DATE
> FROM TRADES WHERE PROCESSED_STATUS = 0
> ORDER BY ENTRY_DATE)
> WHERE ROWNUM < 5
>
> Second SQL statement
> --------------------
> SELECT * FROM
> (SELECT PROCESSED_DATE
> FROM TRADES WHERE PROCESSED_STATUS = 0
> ORDER BY ENTRY_DATE)
> WHERE ROWNUM = 5
>
> ---------------
> Question:
>
> Why second SQL statement does not work?
>
> I would be thankful for the clarification.
>
> Thanks,
>
> Rao
> [EMAIL PROTECTED]
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Rao, Maheswara
> 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).
>
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: orclbabu
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).