Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: help how get the n top rows for any table?

Re: help how get the n top rows for any table?

From: Stas <stant_98_at_yahoo.com>
Date: Tue, 10 Jul 2001 10:35:27 -0700
Message-ID: <F001.0034600F.20010710104145@fatcity.com>

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!


Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
-- 
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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US