Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: help how get the n top rows for any table?
If you're running Oracle8i,
you can do this:
SELECT *
FROM (SELECT * FROM my_table ORDER BY col_name_1
DESC)
WHERE ROWNUM < 10;
Use this workaround with prior releases:
SELECT *
FROM my_table a
WHERE 10 >= (SELECT COUNT(DISTINCT maxcol)
FROM my_table b WHERE b.maxcol >= a.maxcol) ORDER BY maxcol DESC
Hope this helps!
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stas INET: stant_98_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 Tue Jul 10 2001 - 12:35:27 CDT
![]() |
![]() |