Am Donnerstag, 5. Juni 2003 19:28 schrieb Amit Ghaste: > rownum is assigned before the order by is performed > > therfore the retured rows wont the the last 5 rows of the database. > but u will get the first five rows which are then ordered by sal or > row id ... which wont change.. > > ROWNUM IS ASSIGNED PREVIOUS TO ORDER BY > > i would say use a subquery to get the max(ROWID) + the 4 rowids > lesser than that. then find the max of salary on them
Just to add that 'rowid' ist a pseudo-column and string-typed, so keep heed of possible string-sorting pitfalls at least. Apart from that, Oracle rowids tend to change with each server version. Generally, this pseudo column exists for the sole purpose of exactly identifiying a certain database row, but doesn't help otherwise. In particular, the shortcomings of an improper database design can't be 'retro-healed' via using rowid, and it can't and shouldn't be used as a replacement in case of a poor database design. In particular, rowid doesn't replace the need for a (usually sequence-generated) ID column or timestamps and shouldn't be misused this way. Rownum, on the other hand (available since 8i) works on the result set delivered by the query; it may be applied before or after the ORDER BY clause, but order makes no real difference if there are only SQL aggregate functions involved which always deliver a single result. > Hope that helps > Amit HTH, -- Chris (SCPJ2) -- CLIP! =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com
